cocos2d-x  3.3rc0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cocos2d::StringUtils Namespace Reference

Functions

CC_DLL bool  (const std::string &utf8, std::u16string &outUtf16)
 Converts utf8 string to utf16 string. More...
 
var  ( var utf8, var outUtf16)
 Converts utf8 string to utf16 string. More...
 
local  ( local utf8, local outUtf16)
 Converts utf8 string to utf16 string. More...
 
CC_DLL bool  (const std::u16string &utf16, std::string &outUtf8)
 Converts utf16 string to utf8 string. More...
 
local  ( local utf16, local outUtf8)
 Converts utf16 string to utf8 string. More...
 
CC_DLL void  (std::vector< char16_t > &str)
 Trims the unicode spaces at the end of char16_t vector. More...
 
var  ( var str)
 Trims the unicode spaces at the end of char16_t vector. More...
 
local  ( local str)
 Trims the unicode spaces at the end of char16_t vector. More...
 
CC_DLL bool  (char16_t ch)
 Whether the character is a whitespace character. More...
 
var  ( var ch)
 Whether the character is a whitespace character. More...
 
local  ( local ch)
 Whether the character is a whitespace character. More...
 
CC_DLL bool  (char16_t ch)
 Whether the character is a Chinese/Japanese/Korean character. More...
 
CC_DLL long  (const std::string &utf8)
 Returns the length of the string in characters. More...
 
local  ( local utf8)
 Returns the length of the string in characters. More...
 
CC_DLL unsigned int  (const std::vector< char16_t > &str, char16_t c)
 Gets the index of the last character that is not equal to the character given. More...
 
CC_DLL std::vector< char16_t >  (const std::u16string &utf16)
 Gets char16_t vector from a given utf16 string. More...
 
template<typename T >
std::string  (T arg)
template<typename T >
var  ( var arg)
template<typename T >
local  ( local arg)
std::string CC_DLL  (const char *format,...) CC_FORMAT_PRINTF(1
var  ( var format)
local  ( local format)

Function Documentation

CC_DLL bool
cocos2d::StringUtils::UTF8ToUTF16
( const std::string &  utf8,
std::u16string &  outUtf16 
)

Converts utf8 string to utf16 string.

Parameters
utf8The utf8 string to be converted
outUtf16The output utf16 string
Returns
true if succeed, otherwise false
Note
Please check the return value before using outUtf16 e.g.
std::u16string utf16;
bool ret = StringUtils::UTF8ToUTF16("你好hello", utf16);
if (ret) {
do_some_thing_with_utf16(utf16);
}
var UTF8ToUTF16 ( var  utf8,
var  outUtf16 
)

Converts utf8 string to utf16 string.

Parameters
utf8The utf8 string to be converted
outUtf16The output utf16 string
Returns
true if succeed, otherwise false
Note
Please check the return value before using outUtf16 e.g.
std::u16string utf16;
bool ret = StringUtils::UTF8ToUTF16("你好hello", utf16);
if (ret) {
do_some_thing_with_utf16(utf16);
}
local UTF8ToUTF16 ( local  utf8,
local  outUtf16 
)

Converts utf8 string to utf16 string.

Parameters
utf8The utf8 string to be converted
outUtf16The output utf16 string
Returns
true if succeed, otherwise false
Note
Please check the return value before using outUtf16 e.g.
std::u16string utf16;
bool ret = StringUtils::UTF8ToUTF16("你好hello", utf16);
if (ret) {
do_some_thing_with_utf16(utf16);
}
CC_DLL bool
cocos2d::StringUtils::UTF16ToUTF8
( const std::u16string &  utf16,
std::string &  outUtf8 
)

Converts utf16 string to utf8 string.

Parameters
utf16The utf16 string to be converted
outUtf8The output utf8 string
Returns
true if succeed, otherwise false
Note
Please check the return value before using outUtf8 e.g.
std::string utf8;
bool ret = StringUtils::UTF16ToUTF8(u"\u4f60\u597d", utf16);
if (ret) {
do_some_thing_with_utf8(utf8);
}
var UTF16ToUTF8 ( var  utf16,
var  outUtf8 
)

Converts utf16 string to utf8 string.

Parameters
utf16The utf16 string to be converted
outUtf8The output utf8 string
Returns
true if succeed, otherwise false
Note
Please check the return value before using outUtf8 e.g.
std::string utf8;
bool ret = StringUtils::UTF16ToUTF8(u"\u4f60\u597d", utf16);
if (ret) {
do_some_thing_with_utf8(utf8);
}
local UTF16ToUTF8 ( local  utf16,
local  outUtf8 
)

Converts utf16 string to utf8 string.

Parameters
utf16The utf16 string to be converted
outUtf8The output utf8 string
Returns
true if succeed, otherwise false
Note
Please check the return value before using outUtf8 e.g.
std::string utf8;
bool ret = StringUtils::UTF16ToUTF8(u"\u4f60\u597d", utf16);
if (ret) {
do_some_thing_with_utf8(utf8);
}
CC_DLL void
cocos2d::StringUtils::trimUTF16Vector
( std::vector< char16_t > &  str)

Trims the unicode spaces at the end of char16_t vector.

var trimUTF16Vector ( var  str)

Trims the unicode spaces at the end of char16_t vector.

local trimUTF16Vector ( local  str)

Trims the unicode spaces at the end of char16_t vector.

CC_DLL bool
cocos2d::StringUtils::isUnicodeSpace
( char16_t  ch)

Whether the character is a whitespace character.

Parameters
chthe unicode character
Returns
whether the character is a white space character.
See also
http://en.wikipedia.org/wiki/Whitespace_character#Unicode
var isUnicodeSpace ( var  ch)

Whether the character is a whitespace character.

Parameters
chthe unicode character
Returns
whether the character is a white space character.
See also
http://en.wikipedia.org/wiki/Whitespace_character#Unicode
local isUnicodeSpace ( local  ch)

Whether the character is a whitespace character.

Parameters
chthe unicode character
Returns
whether the character is a white space character.
See also
http://en.wikipedia.org/wiki/Whitespace_character#Unicode
CC_DLL bool
cocos2d::StringUtils::isCJKUnicode
( char16_t  ch)

Whether the character is a Chinese/Japanese/Korean character.

Parameters
chthe unicode character
Returns
whether the character is a Chinese character.
See also
http://www.searchtb.com/2012/04/chinese_encode.html
http://tieba.baidu.com/p/748765987
var isCJKUnicode ( var  ch)

Whether the character is a Chinese/Japanese/Korean character.

Parameters
chthe unicode character
Returns
whether the character is a Chinese character.
See also
http://www.searchtb.com/2012/04/chinese_encode.html
http://tieba.baidu.com/p/748765987
local isCJKUnicode ( local  ch)

Whether the character is a Chinese/Japanese/Korean character.

Parameters
chthe unicode character
Returns
whether the character is a Chinese character.
See also
http://www.searchtb.com/2012/04/chinese_encode.html
http://tieba.baidu.com/p/748765987
CC_DLL long
cocos2d::StringUtils::getCharacterCountInUTF8String
( const std::string &  utf8)

Returns the length of the string in characters.

Parameters
utf8an UTF-8 encoded string.
Returns
the length of the string in characters
var getCharacterCountInUTF8String ( var  utf8)

Returns the length of the string in characters.

Parameters
utf8an UTF-8 encoded string.
Returns
the length of the string in characters
local getCharacterCountInUTF8String ( local  utf8)

Returns the length of the string in characters.

Parameters
utf8an UTF-8 encoded string.
Returns
the length of the string in characters
CC_DLL unsigned int
cocos2d::StringUtils::getIndexOfLastNotChar16
( const std::vector< char16_t > &  str,
char16_t  c 
)

Gets the index of the last character that is not equal to the character given.

Parameters
strthe string to be searched.
cthe character to be searched for.
Returns
the index of the last character that is not c.
var getIndexOfLastNotChar16 ( var  str,
var  c 
)

Gets the index of the last character that is not equal to the character given.

Parameters
strthe string to be searched.
cthe character to be searched for.
Returns
the index of the last character that is not c.
local getIndexOfLastNotChar16 ( local  str,
local  c 
)

Gets the index of the last character that is not equal to the character given.

Parameters
strthe string to be searched.
cthe character to be searched for.
Returns
the index of the last character that is not c.
CC_DLL std::vector<char16_t>
cocos2d::StringUtils::getChar16VectorFromUTF16String
( const std::u16string &  utf16)

Gets char16_t vector from a given utf16 string.

var getChar16VectorFromUTF16String ( var  utf16)

Gets char16_t vector from a given utf16 string.

local
getChar16VectorFromUTF16String
( local  utf16)

Gets char16_t vector from a given utf16 string.

std::string
cocos2d::StringUtils::toString
( arg)
var toString ( var  arg)
local toString ( local  arg)
std::string CC_DLL
cocos2d::StringUtils::format
( const char *  format,
  ... 
)
var format ( var  format,
  ... 
)
local format ( local  format,
  ... 
)