clan::StringHelp Class Reference - ClanLib SDK
Description: clan::StringHelp Class Reference

Public Types | Static Public Member Functions | List of all members
clan::StringHelp Class Reference
clanCore Text

String helper functions. More...

`#include <string_help.h>`

## Public Types
enum | BOMType { bom_none , bom_utf32_be , bom_utf32_le , bom_utf16_be , bom_utf16_le , bom_utf8 }

## Static Public Member Functions
static std::string | bool_to_local8 (bool value)
| Bool to local8.
static std::string | bool_to_text (bool value)
| Bool to text.
static std::wstring | bool_to_ucs2 (bool value)
| Bool to ucs2.
static int | compare (const std::string &a, const std::string &b, bool case_insensitive=false)
| Compare.
static int | compare (const std::wstring &a, const std::wstring &b, bool case_insensitive=false)
| Compare.
static std::string | cp437_to_text (const std::string &cp437)
| Cp437 to text.
static std::wstring | cp437_to_ucs2 (const std::string &cp437)
| Cp437 to ucs2.
static BOMType | detect_bom (const void *data, std::string::size_type length)
| Detect bom.
static std::string | double_to_local8 (double value, int num_decimal_places=6)
| Double to local8.
static std::string | double_to_text (double value, int num_decimal_places=6)
| Double to text.
static std::wstring | double_to_ucs2 (double value, int num_decimal_places=6)
| Double to ucs2.
static std::string | float_to_local8 (float value, int num_decimal_places=6, bool remove_trailing_zeros=true)
| Float to local8.
static std::string | float_to_text (float value, int num_decimal_places=6, bool remove_trailing_zeros=true)
| Float to text.
static std::wstring | float_to_ucs2 (float value, int num_decimal_places=6, bool remove_trailing_zeros=true)
| Float to ucs2.
static std::string | int_to_local8 (int value)
| Int to local8.
static std::string | int_to_text (int value)
| Int to text.
static std::wstring | int_to_ucs2 (int value)
| Int to ucs2.
static std::wstring | latin1_to_ucs2 (const std::string &latin1)
| Latin1 to ucs2.
static std::wstring | latin9_to_ucs2 (const std::string &latin9)
| Latin9 to ucs2.
static std::string | ll_to_local8 (long long value)
| Long long to local8.
static std::string | ll_to_text (long long value)
| Long long to text.
static std::wstring | ll_to_ucs2 (long long value)
| Long long to ucs2.
static bool | local8_to_bool (const std::string &value)
| Local8 to bool.
static double | local8_to_double (const std::string &value)
| Local8 to double.
static float | local8_to_float (const std::string &value)
| Local8 to float.
static int | local8_to_int (const std::string &value, int base=10)
| Local8 to int.
static long long | local8_to_ll (const std::string &value, int base=10)
| Local8 to long long.
static std::string | local8_to_lower (const std::string &s)
| Local8 to lower.
static std::wstring | local8_to_ucs2 (const std::string &local8)
| Local8 to ucs2.
static unsigned int | local8_to_uint (const std::string &value, int base=10)
static unsigned long long | local8_to_ull (const std::string &value, int base=10)
| Local8 to unsigned long long.
static std::string | local8_to_upper (const std::string &s)
| Local8 to upper.
static std::string | remove_trailing_zeros (std::string text)
| Removes trailing zeros from floating point numbers.
static std::wstring | remove_trailing_zeros (std::wstring text)
static std::vector< std::string > | split_text (const std::string &text, const std::string &split_string, bool skip_empty=true)
static bool | text_to_bool (const std::string &value)
| Text to bool.
static std::string | text_to_cp437 (const std::string &text)
| Text to cp437.
static double | text_to_double (const std::string &value)
| Text to double.
static float | text_to_float (const std::string &value)
| Text to float.
static int | text_to_int (const std::string &value, int base=10)
| Text to int.
static long long | text_to_ll (const std::string &value, int base=10)
| Text to long long.
static std::string | text_to_lower (const std::string &s)
| Text to lower.
static unsigned int | text_to_uint (const std::string &value, int base=10)
static unsigned long long | text_to_ull (const std::string &value, int base=10)
| Text to unsigned long long.
static std::string | text_to_upper (const std::string &s)
| Text to upper.
static std::string | trim (const std::string &text)
| Trim.
static bool | ucs2_to_bool (const std::wstring &value)
| Ucs2 to bool.
static std::string | ucs2_to_cp437 (const std::wstring &text)
| Ucs2 to cp437.
static double | ucs2_to_double (const std::wstring &value)
| Ucs2 to double.
static float | ucs2_to_float (const std::wstring &value)
| Ucs2 to float.
static int | ucs2_to_int (const std::wstring &value, int base=10)
| Ucs2 to int.
static std::string | ucs2_to_latin1 (const std::wstring &ucs2)
| Ucs2 to latin1.
static std::string | ucs2_to_latin9 (const std::wstring &ucs2)
| Ucs2 to latin9.
static long long | ucs2_to_ll (const std::wstring &value, int base=10)
| Ucs2 to long long.
static std::string | ucs2_to_local8 (const std::wstring &ucs2)
| Ucs2 to local8.
static std::wstring | ucs2_to_lower (const std::wstring &s)
| Ucs2 to lower.
static std::string | ucs2_to_text (const std::wstring &ucs2)
| Ucs2 to text.
static unsigned int | ucs2_to_uint (const std::wstring &value, int base=10)
static unsigned long long | ucs2_to_ull (const std::wstring &value, int base=10)
| Ucs2 to unsigned long long.
static std::wstring | ucs2_to_upper (const std::wstring &s)
| Ucs2 to upper.
static std::string | ucs2_to_utf8 (const std::wstring &ucs2)
| Ucs2 to utf8.
static std::string | uint_to_local8 (unsigned int value)
| Uint to local8.
static std::string | uint_to_text (unsigned int value)
| Uint to text.
static std::wstring | uint_to_ucs2 (unsigned int value)
| Uint to ucs2.
static std::string | ull_to_local8 (unsigned long long value)
| Unsigned long long to local8.
static std::string | ull_to_text (unsigned long long value)
| Unsigned long long to text.
static std::wstring | ull_to_ucs2 (unsigned long long value)
| Unsigned long long to ucs2.
static std::string | unicode_to_utf8 (unsigned int value)
| unicode char to utf-8
static std::string::size_type | utf8_length (const std::string &str)
static std::string | utf8_to_text (const std::string &utf8)
| Utf8 to text.
static std::wstring | utf8_to_ucs2 (const std::string &utf8)
| Utf8 to ucs2.
static std::string | wchar_to_utf8 (wchar_t value)
| Wide char to utf-8.

## Detailed Description

String helper functions.

## Member Enumeration Documentation

## ◆ BOMType

enum clan::StringHelp::BOMType

Enumerator
bom_none |
bom_utf32_be |
bom_utf32_le |
bom_utf16_be |
bom_utf16_le |
bom_utf8 |

## Member Function Documentation

## ◆ bool_to_local8()

std::string clan::StringHelp::bool_to_local8 | ( | bool | value | ) |
| static

Bool to local8.

Parameters

  value | = bool

Returns
  Temp String8

## ◆ bool_to_text()

std::string clan::StringHelp::bool_to_text | ( | bool | value | ) |
| static

Bool to text.

Parameters

  value | = bool

Returns
  Temp String

## ◆ bool_to_ucs2()

std::wstring clan::StringHelp::bool_to_ucs2 | ( | bool | value | ) |
| static

Bool to ucs2.

Parameters

  value | = bool

Returns
  Temp String16

## ◆ compare() [1/2]

int clan::StringHelp::compare | ( | const std::string & | a,
|  | const std::string & | b,
|  | bool | case_insensitive = false )
| static

Compare.

Parameters

  a | = String Ref8
  b | = String Ref8
  case_insensitive | = bool

Returns
  int

References clan::a, and clan::b.

## ◆ compare() [2/2]

int clan::StringHelp::compare | ( | const std::wstring & | a,
|  | const std::wstring & | b,
|  | bool | case_insensitive = false )
| static

Compare.

Parameters

  a | = String Ref16
  b | = String Ref16
  case_insensitive | = bool

Returns
  int

References clan::a, and clan::b.

## ◆ cp437_to_text()

std::string clan::StringHelp::cp437_to_text | ( | const std::string & | cp437 | ) |
| static

Cp437 to text.

Parameters

  cp437 | = String Ref8

Returns
  Temp String

## ◆ cp437_to_ucs2()

std::wstring clan::StringHelp::cp437_to_ucs2 | ( | const std::string & | cp437 | ) |
| static

Cp437 to ucs2.

Parameters

  cp437 | = String Ref8

Returns
  Temp String16

## ◆ detect_bom()

BOMType clan::StringHelp::detect_bom | ( | const void * | data,
|  | std::string::size_type | length )
| static

Detect bom.

Parameters

  data | = void
  size_type | = String

Returns
  BOMType

References clan::length.

## ◆ double_to_local8()

std::string clan::StringHelp::double_to_local8 | ( | double | value,
|  | int | num_decimal_places = 6 )
| static

Double to local8.

Parameters

  value | = value
  num_decimal_places | = value

Returns
  Temp String8

## ◆ double_to_text()

std::string clan::StringHelp::double_to_text | ( | double | value,
|  | int | num_decimal_places = 6 )
| static

Double to text.

Parameters

  value | = value
  num_decimal_places | = value

Returns
  Temp String

## ◆ double_to_ucs2()

std::wstring clan::StringHelp::double_to_ucs2 | ( | double | value,
|  | int | num_decimal_places = 6 )
| static

Double to ucs2.

Parameters

  value | = value
  num_decimal_places | = value

Returns
  Temp String16

## ◆ float_to_local8()

std::string clan::StringHelp::float_to_local8 | ( | float | value,
|  | int | num_decimal_places = 6,
|  | bool | remove_trailing_zeros = true )
| static

Float to local8.

Parameters

  value | = value
  num_decimal_places | = value

Returns
  Temp String8

References remove_trailing_zeros().

## ◆ float_to_text()

std::string clan::StringHelp::float_to_text | ( | float | value,
|  | int | num_decimal_places = 6,
|  | bool | remove_trailing_zeros = true )
| static

Float to text.

Parameters

  value | = value
  num_decimal_places | = value

Returns
  Temp String

References remove_trailing_zeros().

## ◆ float_to_ucs2()

std::wstring clan::StringHelp::float_to_ucs2 | ( | float | value,
|  | int | num_decimal_places = 6,
|  | bool | remove_trailing_zeros = true )
| static

Float to ucs2.

Parameters

  value | = value
  num_decimal_places | = value

Returns
  Temp String16

References remove_trailing_zeros().

## ◆ int_to_local8()

std::string clan::StringHelp::int_to_local8 | ( | int | value | ) |
| static

Int to local8.

Parameters

  value | = value

Returns
  Temp String8

## ◆ int_to_text()

std::string clan::StringHelp::int_to_text | ( | int | value | ) |
| static

Int to text.

Parameters

  value | = value

Returns
  Temp String

## ◆ int_to_ucs2()

std::wstring clan::StringHelp::int_to_ucs2 | ( | int | value | ) |
| static

Int to ucs2.

Parameters

  value | = value

Returns
  Temp String16

## ◆ latin1_to_ucs2()

std::wstring clan::StringHelp::latin1_to_ucs2 | ( | const std::string & | latin1 | ) |
| static

Latin1 to ucs2.

Parameters

  latin1 | = String Ref8

Returns
  Temp String16

## ◆ latin9_to_ucs2()

std::wstring clan::StringHelp::latin9_to_ucs2 | ( | const std::string & | latin9 | ) |
| static

Latin9 to ucs2.

Parameters

  latin9 | = String Ref8

Returns
  Temp String16

## ◆ ll_to_local8()

std::string clan::StringHelp::ll_to_local8 | ( | long long | value | ) |
| static

Long long to local8.

Parameters

  value | = value

Returns
  Temp String8

## ◆ ll_to_text()

std::string clan::StringHelp::ll_to_text | ( | long long | value | ) |
| static

Long long to text.

Parameters

  value | = value

Returns
  Temp String

## ◆ ll_to_ucs2()

std::wstring clan::StringHelp::ll_to_ucs2 | ( | long long | value | ) |
| static

Long long to ucs2.

Parameters

  value | = value

Returns
  Temp String16

## ◆ local8_to_bool()

bool clan::StringHelp::local8_to_bool | ( | const std::string & | value | ) |
| static

Local8 to bool.

Parameters

  value | = String Ref8

Returns
  bool

## ◆ local8_to_double()

double clan::StringHelp::local8_to_double | ( | const std::string & | value | ) |
| static

Local8 to double.

Parameters

  value | = String Ref8

Returns
  double

## ◆ local8_to_float()

float clan::StringHelp::local8_to_float | ( | const std::string & | value | ) |
| static

Local8 to float.

Parameters

  value | = String Ref8

Returns
  float

## ◆ local8_to_int()

int clan::StringHelp::local8_to_int | ( | const std::string & | value,
|  | int | base = 10 )
| static

Local8 to int.

Parameters

  value | = String Ref8
  base | = value

Returns
  int

## ◆ local8_to_ll()

long long clan::StringHelp::local8_to_ll | ( | const std::string & | value,
|  | int | base = 10 )
| static

Local8 to long long.

Parameters

  value | = String Ref8
  base | = value

Returns
  long long

## ◆ local8_to_lower()

std::string clan::StringHelp::local8_to_lower | ( | const std::string & | s | ) |
| static

Local8 to lower.

Parameters

  s | = String Ref8

Returns
  Temp String8

References clan::s.

## ◆ local8_to_ucs2()

std::wstring clan::StringHelp::local8_to_ucs2 | ( | const std::string & | local8 | ) |
| static

Local8 to ucs2.

Parameters

  local8 | = String Ref8

Returns
  Temp String16

## ◆ local8_to_uint()

unsigned int clan::StringHelp::local8_to_uint | ( | const std::string & | value,
|  | int | base = 10 )
| static

## ◆ local8_to_ull()

unsigned long long clan::StringHelp::local8_to_ull | ( | const std::string & | value,
|  | int | base = 10 )
| static

Local8 to unsigned long long.

Parameters

  value | = String Ref8
  base | = value

Returns
  unsigned long long

## ◆ local8_to_upper()

std::string clan::StringHelp::local8_to_upper | ( | const std::string & | s | ) |
| static

Local8 to upper.

Parameters

  s | = String Ref8

Returns
  Temp String8

References clan::s.

## ◆ remove_trailing_zeros() [1/2]

std::string clan::StringHelp::remove_trailing_zeros | ( | std::string | text | ) |
| static

Removes trailing zeros from floating point numbers.

If the input string is "42.21000", then this function returns "42.21". If the string is "42.00000", then it returns "42".

Referenced by float_to_local8(), float_to_text(), and float_to_ucs2().

## ◆ remove_trailing_zeros() [2/2]

std::wstring clan::StringHelp::remove_trailing_zeros | ( | std::wstring | text | ) |
| static

## ◆ split_text()

std::vector< std::string > clan::StringHelp::split_text | ( | const std::string & | text,
|  | const std::string & | split_string,
|  | bool | skip_empty = true )
| static

## ◆ text_to_bool()

bool clan::StringHelp::text_to_bool | ( | const std::string & | value | ) |
| static

Text to bool.

Parameters

  value | = String Ref

Returns
  bool

## ◆ text_to_cp437()

std::string clan::StringHelp::text_to_cp437 | ( | const std::string & | text | ) |
| static

Text to cp437.

Parameters

  text | = String Ref

Returns
  Temp String8

## ◆ text_to_double()

double clan::StringHelp::text_to_double | ( | const std::string & | value | ) |
| static

Text to double.

Parameters

  value | = String Ref

Returns
  double

## ◆ text_to_float()

float clan::StringHelp::text_to_float | ( | const std::string & | value | ) |
| static

Text to float.

Parameters

  value | = String Ref

Returns
  float

## ◆ text_to_int()

int clan::StringHelp::text_to_int | ( | const std::string & | value,
|  | int | base = 10 )
| static

Text to int.

Parameters

  value | = String Ref
  base | = value

Returns
  int

## ◆ text_to_ll()

long long clan::StringHelp::text_to_ll | ( | const std::string & | value,
|  | int | base = 10 )
| static

Text to long long.

Parameters

  value | = String Ref
  base | = value

Returns
  long long

## ◆ text_to_lower()

std::string clan::StringHelp::text_to_lower | ( | const std::string & | s | ) |
| static

Text to lower.

Parameters

  s | = String Ref

Returns
  Temp String

References clan::s.

## ◆ text_to_uint()

unsigned int clan::StringHelp::text_to_uint | ( | const std::string & | value,
|  | int | base = 10 )
| static

## ◆ text_to_ull()

unsigned long long clan::StringHelp::text_to_ull | ( | const std::string & | value,
|  | int | base = 10 )
| static

Text to unsigned long long.

Parameters

  value | = String Ref
  base | = value

Returns
  unsigned long long

## ◆ text_to_upper()

std::string clan::StringHelp::text_to_upper | ( | const std::string & | s | ) |
| static

Text to upper.

Parameters

  s | = String Ref

Returns
  Temp String

References clan::s.

## ◆ trim()

std::string clan::StringHelp::trim | ( | const std::string & | text | ) |
| static

Trim.

Parameters

  text | = String Ref

Returns
  Temp String

## ◆ ucs2_to_bool()

bool clan::StringHelp::ucs2_to_bool | ( | const std::wstring & | value | ) |
| static

Ucs2 to bool.

Parameters

  value | = String Ref16

Returns
  bool

## ◆ ucs2_to_cp437()

std::string clan::StringHelp::ucs2_to_cp437 | ( | const std::wstring & | text | ) |
| static

Ucs2 to cp437.

Parameters

  text | = String Ref16

Returns
  Temp String8

## ◆ ucs2_to_double()

double clan::StringHelp::ucs2_to_double | ( | const std::wstring & | value | ) |
| static

Ucs2 to double.

Parameters

  value | = String Ref16

Returns
  double

## ◆ ucs2_to_float()

float clan::StringHelp::ucs2_to_float | ( | const std::wstring & | value | ) |
| static

Ucs2 to float.

Parameters

  value | = String Ref16

Returns
  float

## ◆ ucs2_to_int()

int clan::StringHelp::ucs2_to_int | ( | const std::wstring & | value,
|  | int | base = 10 )
| static

Ucs2 to int.

Parameters

  value | = String Ref16
  base | = value

Returns
  int

## ◆ ucs2_to_latin1()

std::string clan::StringHelp::ucs2_to_latin1 | ( | const std::wstring & | ucs2 | ) |
| static

Ucs2 to latin1.

Parameters

  ucs2 | = String Ref16

Returns
  Temp String8

## ◆ ucs2_to_latin9()

std::string clan::StringHelp::ucs2_to_latin9 | ( | const std::wstring & | ucs2 | ) |
| static

Ucs2 to latin9.

Parameters

  ucs2 | = String Ref16

Returns
  Temp String8

## ◆ ucs2_to_ll()

long long clan::StringHelp::ucs2_to_ll | ( | const std::wstring & | value,
|  | int | base = 10 )
| static

Ucs2 to long long.

Parameters

  value | = String Ref16
  base | = value

Returns
  long long

## ◆ ucs2_to_local8()

std::string clan::StringHelp::ucs2_to_local8 | ( | const std::wstring & | ucs2 | ) |
| static

Ucs2 to local8.

Parameters

  ucs2 | = String Ref16

Returns
  Temp String8

## ◆ ucs2_to_lower()

std::wstring clan::StringHelp::ucs2_to_lower | ( | const std::wstring & | s | ) |
| static

Ucs2 to lower.

Parameters

  s | = String Ref16

Returns
  Temp String16

References clan::s.

## ◆ ucs2_to_text()

std::string clan::StringHelp::ucs2_to_text | ( | const std::wstring & | ucs2 | ) |
| static

Ucs2 to text.

Parameters

  ucs2 | = String Ref16

Returns
  Temp String

## ◆ ucs2_to_uint()

unsigned int clan::StringHelp::ucs2_to_uint | ( | const std::wstring & | value,
|  | int | base = 10 )
| static

## ◆ ucs2_to_ull()

unsigned long long clan::StringHelp::ucs2_to_ull | ( | const std::wstring & | value,
|  | int | base = 10 )
| static

Ucs2 to unsigned long long.

Parameters

  value | = String Ref16
  base | = value

Returns
  unsigned long long

## ◆ ucs2_to_upper()

std::wstring clan::StringHelp::ucs2_to_upper | ( | const std::wstring & | s | ) |
| static

Ucs2 to upper.

Parameters

  s | = String Ref16

Returns
  Temp String16

References clan::s.

## ◆ ucs2_to_utf8()

std::string clan::StringHelp::ucs2_to_utf8 | ( | const std::wstring & | ucs2 | ) |
| static

Ucs2 to utf8.

Parameters

  ucs2 | = String Ref16

Returns
  Temp String8

## ◆ uint_to_local8()

std::string clan::StringHelp::uint_to_local8 | ( | unsigned int | value | ) |
| static

Uint to local8.

Parameters

  value | = value

Returns
  Temp String8

## ◆ uint_to_text()

std::string clan::StringHelp::uint_to_text | ( | unsigned int | value | ) |
| static

Uint to text.

Parameters

  value | = value

Returns
  Temp String

## ◆ uint_to_ucs2()

std::wstring clan::StringHelp::uint_to_ucs2 | ( | unsigned int | value | ) |
| static

Uint to ucs2.

Parameters

  value | = value

Returns
  Temp String16

## ◆ ull_to_local8()

std::string clan::StringHelp::ull_to_local8 | ( | unsigned long long | value | ) |
| static

Unsigned long long to local8.

Parameters

  value | = value

Returns
  Temp String8

## ◆ ull_to_text()

std::string clan::StringHelp::ull_to_text | ( | unsigned long long | value | ) |
| static

Unsigned long long to text.

Parameters

  value | = value

Returns
  Temp String

## ◆ ull_to_ucs2()

std::wstring clan::StringHelp::ull_to_ucs2 | ( | unsigned long long | value | ) |
| static

Unsigned long long to ucs2.

Parameters

  value | = value

Returns
  Temp String16

## ◆ unicode_to_utf8()

std::string clan::StringHelp::unicode_to_utf8 | ( | unsigned int | value | ) |
| static

unicode char to utf-8

Parameters

  value | = unicode char value

Returns
  The UTF-8 String

## ◆ utf8_length()

std::string::size_type clan::StringHelp::utf8_length | ( | const std::string & | str | ) |
| static

## ◆ utf8_to_text()

std::string clan::StringHelp::utf8_to_text | ( | const std::string & | utf8 | ) |
| static

Utf8 to text.

Parameters

  utf8 | = String Ref8

Returns
  Temp String

## ◆ utf8_to_ucs2()

std::wstring clan::StringHelp::utf8_to_ucs2 | ( | const std::string & | utf8 | ) |
| static

Utf8 to ucs2.

Parameters

  utf8 | = String Ref8

Returns
  Temp String16

## ◆ wchar_to_utf8()

std::string clan::StringHelp::wchar_to_utf8 | ( | wchar_t | value | ) |
| static

Wide char to utf-8.

Parameters

  value | = Wide char value

Returns
  The UTF-8 String

The documentation for this class was generated from the following file:

- string_help.h