mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Added conversion from String to const wchar_t*
This commit is contained in:
parent
7e866e11ad
commit
62d55223b2
@ -312,6 +312,11 @@ const char *String::toCString(bool unicode) const
|
||||
return d->cstring.c_str();
|
||||
}
|
||||
|
||||
const wchar_t *String::toCWString() const
|
||||
{
|
||||
return d->data.c_str();
|
||||
}
|
||||
|
||||
String::Iterator String::begin()
|
||||
{
|
||||
return d->data.begin();
|
||||
|
@ -205,7 +205,16 @@ namespace TagLib {
|
||||
* where memory is critical.
|
||||
*/
|
||||
const char *toCString(bool unicode = false) const;
|
||||
|
||||
|
||||
/*!
|
||||
* Returns a pointer to the wide char version of the TagLib string. The string
|
||||
* is encoded in UTF-16(without BOM/CPU byte order).
|
||||
*
|
||||
* /note This returns a pointer to the String's internal data without any
|
||||
* conversions.
|
||||
*/
|
||||
const wchar_t *toCWString() const;
|
||||
|
||||
/*!
|
||||
* Returns an iterator pointing to the beginning of the string.
|
||||
*/
|
||||
|
@ -72,6 +72,9 @@ public:
|
||||
String unicode2(unicode.to8Bit(true), String::UTF8);
|
||||
CPPUNIT_ASSERT(unicode == unicode2);
|
||||
|
||||
String unicode3(L"\u65E5\u672C\u8A9E");
|
||||
CPPUNIT_ASSERT(*(unicode3.toCWString() + 1) == L'\u672C');
|
||||
|
||||
CPPUNIT_ASSERT(strcmp(String::number(0).toCString(), "0") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(String::number(12345678).toCString(), "12345678") == 0);
|
||||
CPPUNIT_ASSERT(strcmp(String::number(-12345678).toCString(), "-12345678") == 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user