OVR_String.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /************************************************************************************
  2. PublicHeader: OVR_Kernel.h
  3. Filename : OVR_String.h
  4. Content : String UTF8 string implementation with copy-on-write semantics
  5. (thread-safe for assignment but not modification).
  6. Created : September 19, 2012
  7. Notes :
  8. Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
  9. Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
  10. you may not use the Oculus VR Rift SDK except in compliance with the License,
  11. which is provided at the time of installation or download, or which
  12. otherwise accompanies this software in either electronic or hard copy form.
  13. You may obtain a copy of the License at
  14. http://www.oculusvr.com/licenses/LICENSE-3.2
  15. Unless required by applicable law or agreed to in writing, the Oculus VR SDK
  16. distributed under the License is distributed on an "AS IS" BASIS,
  17. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. See the License for the specific language governing permissions and
  19. limitations under the License.
  20. ************************************************************************************/
  21. #ifndef OVR_String_h
  22. #define OVR_String_h
  23. #include "OVR_Types.h"
  24. #include "OVR_Allocator.h"
  25. #include "OVR_UTF8Util.h"
  26. #include "OVR_Atomic.h"
  27. #include "OVR_Std.h"
  28. #include "OVR_Alg.h"
  29. #include <string>
  30. namespace OVR {
  31. // ***** Classes
  32. class String;
  33. class StringBuffer;
  34. //-----------------------------------------------------------------------------------
  35. // ***** String Class
  36. // String is UTF8 based string class with copy-on-write implementation
  37. // for assignment.
  38. class String
  39. {
  40. protected:
  41. enum FlagConstants
  42. {
  43. //Flag_GetLength = 0x7FFFFFFF,
  44. // This flag is set if GetLength() == GetSize() for a string.
  45. // Avoid extra scanning is Substring and indexing logic.
  46. Flag_LengthIsSizeShift = (sizeof(size_t)*8 - 1)
  47. };
  48. // Internal structure to hold string data
  49. struct DataDesc
  50. {
  51. // Number of bytes. Will be the same as the number of chars if the characters
  52. // are ascii, may not be equal to number of chars in case string data is UTF8.
  53. size_t Size;
  54. AtomicInt<int32_t> RefCount;
  55. char Data[1];
  56. void AddRef()
  57. {
  58. RefCount.ExchangeAdd_NoSync(1);
  59. }
  60. // Decrement ref count. This needs to be thread-safe, since
  61. // a different thread could have also decremented the ref count.
  62. // For example, if u start off with a ref count = 2. Now if u
  63. // decrement the ref count and check against 0 in different
  64. // statements, a different thread can also decrement the ref count
  65. // in between our decrement and checking against 0 and will find
  66. // the ref count = 0 and delete the object. This will lead to a crash
  67. // when context switches to our thread and we'll be trying to delete
  68. // an already deleted object. Hence decrementing the ref count and
  69. // checking against 0 needs to made an atomic operation.
  70. void Release()
  71. {
  72. if ((RefCount.ExchangeAdd_NoSync(-1) - 1) == 0)
  73. OVR_FREE(this);
  74. }
  75. static size_t GetLengthFlagBit() { return size_t(1) << Flag_LengthIsSizeShift; }
  76. size_t GetSize() const { return Size & ~GetLengthFlagBit() ; }
  77. size_t GetLengthFlag() const { return Size & GetLengthFlagBit(); }
  78. bool LengthIsSize() const { return GetLengthFlag() != 0; }
  79. };
  80. // Heap type of the string is encoded in the lower bits.
  81. enum HeapType
  82. {
  83. HT_Global = 0, // Heap is global.
  84. HT_Local = 1, // SF::String_loc: Heap is determined based on string's address.
  85. HT_Dynamic = 2, // SF::String_temp: Heap is stored as a part of the class.
  86. HT_Mask = 3
  87. };
  88. union {
  89. DataDesc* pData;
  90. size_t HeapTypeBits;
  91. };
  92. typedef union {
  93. DataDesc* pData;
  94. size_t HeapTypeBits;
  95. } DataDescUnion;
  96. inline HeapType GetHeapType() const { return (HeapType) (HeapTypeBits & HT_Mask); }
  97. inline DataDesc* GetData() const
  98. {
  99. DataDescUnion u;
  100. u.pData = pData;
  101. u.HeapTypeBits = (u.HeapTypeBits & ~(size_t)HT_Mask);
  102. return u.pData;
  103. }
  104. inline void SetData(DataDesc* pdesc)
  105. {
  106. HeapType ht = GetHeapType();
  107. pData = pdesc;
  108. OVR_ASSERT((HeapTypeBits & HT_Mask) == 0);
  109. HeapTypeBits |= ht;
  110. }
  111. DataDesc* AllocData(size_t size, size_t lengthIsSize);
  112. DataDesc* AllocDataCopy1(size_t size, size_t lengthIsSize,
  113. const char* pdata, size_t copySize);
  114. DataDesc* AllocDataCopy2(size_t size, size_t lengthIsSize,
  115. const char* pdata1, size_t copySize1,
  116. const char* pdata2, size_t copySize2);
  117. // Special constructor to avoid data initalization when used in derived class.
  118. struct NoConstructor { };
  119. String(const NoConstructor&) { }
  120. public:
  121. // For initializing string with dynamic buffer
  122. struct InitStruct
  123. {
  124. virtual ~InitStruct() { }
  125. virtual void InitString(char* pbuffer, size_t size) const = 0;
  126. };
  127. // Constructors / Destructors.
  128. String();
  129. String(const char* data);
  130. String(const char* data1, const char* pdata2, const char* pdata3 = 0);
  131. String(const char* data, size_t buflen);
  132. String(const String& src);
  133. String(const StringBuffer& src);
  134. String(const InitStruct& src, size_t size);
  135. explicit String(const wchar_t* data);
  136. // Destructor (Captain Obvious guarantees!)
  137. ~String()
  138. {
  139. GetData()->Release();
  140. }
  141. // Declaration of NullString
  142. static DataDesc NullData;
  143. // *** General Functions
  144. void Clear();
  145. // For casting to a pointer to char.
  146. operator const char*() const { return GetData()->Data; }
  147. // Pointer to raw buffer.
  148. const char* ToCStr() const { return GetData()->Data; }
  149. // Returns number of bytes
  150. size_t GetSize() const { return GetData()->GetSize() ; }
  151. // Tells whether or not the string is empty
  152. bool IsEmpty() const { return GetSize() == 0; }
  153. // Returns number of characters
  154. size_t GetLength() const;
  155. int GetLengthI() const { return (int)GetLength(); }
  156. // Returns character at the specified index
  157. uint32_t GetCharAt(size_t index) const;
  158. uint32_t GetFirstCharAt(size_t index, const char** offset) const;
  159. uint32_t GetNextChar(const char** offset) const;
  160. // Appends a character
  161. void AppendChar(uint32_t ch);
  162. // Append a string
  163. void AppendString(const wchar_t* pstr, intptr_t len = -1);
  164. void AppendString(const char* putf8str, intptr_t utf8StrSz = -1);
  165. // Assigned a string with dynamic data (copied through initializer).
  166. void AssignString(const InitStruct& src, size_t size);
  167. // Assigns string with known size.
  168. void AssignString(const char* putf8str, size_t size);
  169. // Resize the string to the new size
  170. // void Resize(size_t _size);
  171. // Removes the character at posAt
  172. void Remove(size_t posAt, intptr_t len = 1);
  173. // Returns a String that's a substring of this.
  174. // -start is the index of the first UTF8 character you want to include.
  175. // -end is the index one past the last UTF8 character you want to include.
  176. String Substring(size_t start, size_t end) const;
  177. // Case-conversion
  178. String ToUpper() const;
  179. String ToLower() const;
  180. // Inserts substr at posAt
  181. String& Insert (const char* substr, size_t posAt, intptr_t len = -1);
  182. // Inserts character at posAt
  183. size_t InsertCharAt(uint32_t c, size_t posAt);
  184. // Inserts substr at posAt, which is an index of a character (not byte).
  185. // Of size is specified, it is in bytes.
  186. // String& Insert(const uint32_t* substr, size_t posAt, intptr_t size = -1);
  187. // Get Byte index of the character at position = index
  188. size_t GetByteIndex(size_t index) const { return (size_t)UTF8Util::GetByteIndex(index, GetData()->Data); }
  189. // Utility: case-insensitive string compare. stricmp() & strnicmp() are not
  190. // ANSI or POSIX, do not seem to appear in Linux.
  191. static int OVR_STDCALL CompareNoCase(const char* a, const char* b);
  192. static int OVR_STDCALL CompareNoCase(const char* a, const char* b, intptr_t len);
  193. // Hash function, case-insensitive
  194. static size_t OVR_STDCALL BernsteinHashFunctionCIS(const void* pdataIn, size_t size, size_t seed = 5381);
  195. // Hash function, case-sensitive
  196. static size_t OVR_STDCALL BernsteinHashFunction(const void* pdataIn, size_t size, size_t seed = 5381);
  197. // ***** File path parsing helper functions.
  198. // Implemented in OVR_String_FilePath.cpp.
  199. // Absolute paths can star with:
  200. // - protocols: 'file://', 'http://'
  201. // - windows drive: 'c:\'
  202. // - UNC share name: '\\share'
  203. // - unix root '/'
  204. static bool HasAbsolutePath(const char* path);
  205. static bool HasExtension(const char* path);
  206. static bool HasProtocol(const char* path);
  207. bool HasAbsolutePath() const { return HasAbsolutePath(ToCStr()); }
  208. bool HasExtension() const { return HasExtension(ToCStr()); }
  209. bool HasProtocol() const { return HasProtocol(ToCStr()); }
  210. String GetProtocol() const; // Returns protocol, if any, with trailing '://'.
  211. String GetPath() const; // Returns path with trailing '/'.
  212. String GetFilename() const; // Returns filename, including extension.
  213. String GetExtension() const; // Returns extension with a dot.
  214. void StripProtocol(); // Strips front protocol, if any, from the string.
  215. void StripExtension(); // Strips off trailing extension.
  216. // Operators
  217. // Assignment
  218. void operator = (const char* str);
  219. void operator = (const wchar_t* str);
  220. void operator = (const String& src);
  221. void operator = (const StringBuffer& src);
  222. // Addition
  223. void operator += (const String& src);
  224. void operator += (const char* psrc) { AppendString(psrc); }
  225. void operator += (const wchar_t* psrc) { AppendString(psrc); }
  226. void operator += (char ch) { AppendChar(ch); }
  227. String operator + (const char* str) const;
  228. String operator + (const String& src) const;
  229. // Comparison
  230. bool operator == (const String& str) const
  231. {
  232. return (OVR_strcmp(GetData()->Data, str.GetData()->Data)== 0);
  233. }
  234. bool operator != (const String& str) const
  235. {
  236. return !operator == (str);
  237. }
  238. bool operator == (const char* str) const
  239. {
  240. return OVR_strcmp(GetData()->Data, str) == 0;
  241. }
  242. bool operator != (const char* str) const
  243. {
  244. return !operator == (str);
  245. }
  246. bool operator < (const char* pstr) const
  247. {
  248. return OVR_strcmp(GetData()->Data, pstr) < 0;
  249. }
  250. bool operator < (const String& str) const
  251. {
  252. return *this < str.GetData()->Data;
  253. }
  254. bool operator > (const char* pstr) const
  255. {
  256. return OVR_strcmp(GetData()->Data, pstr) > 0;
  257. }
  258. bool operator > (const String& str) const
  259. {
  260. return *this > str.GetData()->Data;
  261. }
  262. int CompareNoCase(const char* pstr) const
  263. {
  264. return CompareNoCase(GetData()->Data, pstr);
  265. }
  266. int CompareNoCase(const String& str) const
  267. {
  268. return CompareNoCase(GetData()->Data, str.ToCStr());
  269. }
  270. int CompareNoCaseStartsWith(const String& str) const
  271. {
  272. return CompareNoCase(GetData()->Data, str.ToCStr(), str.GetLength());
  273. }
  274. // Accesses raw bytes
  275. const char& operator [] (int index) const
  276. {
  277. OVR_ASSERT(index >= 0 && (size_t)index < GetSize());
  278. return GetData()->Data[index];
  279. }
  280. const char& operator [] (size_t index) const
  281. {
  282. OVR_ASSERT(index < GetSize());
  283. return GetData()->Data[index];
  284. }
  285. // Case insensitive keys are used to look up insensitive string in hash tables
  286. // for SWF files with version before SWF 7.
  287. struct NoCaseKey
  288. {
  289. const String* pStr;
  290. NoCaseKey(const String &str) : pStr(&str){};
  291. };
  292. bool operator == (const NoCaseKey& strKey) const
  293. {
  294. return (CompareNoCase(ToCStr(), strKey.pStr->ToCStr()) == 0);
  295. }
  296. bool operator != (const NoCaseKey& strKey) const
  297. {
  298. return !(CompareNoCase(ToCStr(), strKey.pStr->ToCStr()) == 0);
  299. }
  300. // Hash functor used for strings.
  301. struct HashFunctor
  302. {
  303. size_t operator()(const String& data) const
  304. {
  305. size_t size = data.GetSize();
  306. return String::BernsteinHashFunction((const char*)data, size);
  307. }
  308. };
  309. // Case-insensitive hash functor used for strings. Supports additional
  310. // lookup based on NoCaseKey.
  311. struct NoCaseHashFunctor
  312. {
  313. size_t operator()(const String& data) const
  314. {
  315. size_t size = data.GetSize();
  316. return String::BernsteinHashFunctionCIS((const char*)data, size);
  317. }
  318. size_t operator()(const NoCaseKey& data) const
  319. {
  320. size_t size = data.pStr->GetSize();
  321. return String::BernsteinHashFunctionCIS((const char*)data.pStr->ToCStr(), size);
  322. }
  323. };
  324. };
  325. //-----------------------------------------------------------------------------------
  326. // ***** String Buffer used for Building Strings
  327. class StringBuffer
  328. {
  329. char* pData;
  330. size_t Size;
  331. size_t BufferSize;
  332. size_t GrowSize;
  333. mutable bool LengthIsSize;
  334. public:
  335. // Constructors / Destructor.
  336. StringBuffer();
  337. explicit StringBuffer(size_t growSize);
  338. StringBuffer(const char* data);
  339. StringBuffer(const char* data, size_t buflen);
  340. StringBuffer(const String& src);
  341. StringBuffer(const StringBuffer& src);
  342. explicit StringBuffer(const wchar_t* data);
  343. ~StringBuffer();
  344. // Modify grow size used for growing/shrinking the buffer.
  345. size_t GetGrowSize() const { return GrowSize; }
  346. void SetGrowSize(size_t growSize);
  347. // *** General Functions
  348. // Does not release memory, just sets Size to 0
  349. void Clear();
  350. // For casting to a pointer to char.
  351. operator const char*() const { return (pData) ? pData : ""; }
  352. // Pointer to raw buffer.
  353. const char* ToCStr() const { return (pData) ? pData : ""; }
  354. // Returns number of bytes.
  355. size_t GetSize() const { return Size ; }
  356. // Tells whether or not the string is empty.
  357. bool IsEmpty() const { return GetSize() == 0; }
  358. // Returns number of characters
  359. size_t GetLength() const;
  360. // Returns character at the specified index
  361. uint32_t GetCharAt(size_t index) const;
  362. uint32_t GetFirstCharAt(size_t index, const char** offset) const;
  363. uint32_t GetNextChar(const char** offset) const;
  364. // Resize the string to the new size
  365. void Resize(size_t _size);
  366. void Reserve(size_t _size);
  367. // Appends a character
  368. void AppendChar(uint32_t ch);
  369. // Append a string
  370. void AppendString(const wchar_t* pstr, intptr_t len = -1);
  371. void AppendString(const char* putf8str, intptr_t utf8StrSz = -1);
  372. void AppendFormatV(const char* format, va_list argList);
  373. void AppendFormat(const char* format, ...);
  374. // Assigned a string with dynamic data (copied through initializer).
  375. //void AssignString(const InitStruct& src, size_t size);
  376. // Inserts substr at posAt
  377. void Insert (const char* substr, size_t posAt, intptr_t len = -1);
  378. // Inserts character at posAt
  379. size_t InsertCharAt(uint32_t c, size_t posAt);
  380. // Assignment
  381. void operator = (const char* str);
  382. void operator = (const wchar_t* str);
  383. void operator = (const String& src);
  384. void operator = (const StringBuffer& src);
  385. // Addition
  386. void operator += (const String& src) { AppendString(src.ToCStr(),src.GetSize()); }
  387. void operator += (const char* psrc) { AppendString(psrc); }
  388. void operator += (const wchar_t* psrc) { AppendString(psrc); }
  389. void operator += (char ch) { AppendChar(ch); }
  390. //String operator + (const char* str) const ;
  391. //String operator + (const String& src) const ;
  392. // Accesses raw bytes
  393. char& operator [] (int index)
  394. {
  395. OVR_ASSERT(((size_t)index) < GetSize());
  396. return pData[index];
  397. }
  398. char& operator [] (size_t index)
  399. {
  400. OVR_ASSERT(index < GetSize());
  401. return pData[index];
  402. }
  403. const char& operator [] (int index) const
  404. {
  405. OVR_ASSERT(((size_t)index) < GetSize());
  406. return pData[index];
  407. }
  408. const char& operator [] (size_t index) const
  409. {
  410. OVR_ASSERT(index < GetSize());
  411. return pData[index];
  412. }
  413. };
  414. //
  415. // Wrapper for string data. The data must have a guaranteed
  416. // lifespan throughout the usage of the wrapper. Not intended for
  417. // cached usage. Not thread safe.
  418. //
  419. class StringDataPtr
  420. {
  421. public:
  422. StringDataPtr() : pStr(NULL), Size(0) {}
  423. StringDataPtr(const StringDataPtr& p)
  424. : pStr(p.pStr), Size(p.Size) {}
  425. StringDataPtr(const char* pstr, size_t sz)
  426. : pStr(pstr), Size(sz) {}
  427. StringDataPtr(const char* pstr)
  428. : pStr(pstr), Size((pstr != NULL) ? OVR_strlen(pstr) : 0) {}
  429. explicit StringDataPtr(const String& str)
  430. : pStr(str.ToCStr()), Size(str.GetSize()) {}
  431. template <typename T, int N>
  432. StringDataPtr(const T (&v)[N])
  433. : pStr(v), Size(N) {}
  434. public:
  435. const char* ToCStr() const { return pStr; }
  436. size_t GetSize() const { return Size; }
  437. bool IsEmpty() const { return GetSize() == 0; }
  438. // value is a prefix of this string
  439. // Character's values are not compared.
  440. bool IsPrefix(const StringDataPtr& value) const
  441. {
  442. return ToCStr() == value.ToCStr() && GetSize() >= value.GetSize();
  443. }
  444. // value is a suffix of this string
  445. // Character's values are not compared.
  446. bool IsSuffix(const StringDataPtr& value) const
  447. {
  448. return ToCStr() <= value.ToCStr() && (End()) == (value.End());
  449. }
  450. // Find first character.
  451. // init_ind - initial index.
  452. intptr_t FindChar(char c, size_t init_ind = 0) const
  453. {
  454. for (size_t i = init_ind; i < GetSize(); ++i)
  455. if (pStr[i] == c)
  456. return static_cast<intptr_t>(i);
  457. return -1;
  458. }
  459. // Find last character.
  460. // init_ind - initial index.
  461. intptr_t FindLastChar(char c, size_t init_ind = ~0) const
  462. {
  463. if (init_ind == (size_t)~0 || init_ind > GetSize())
  464. init_ind = GetSize();
  465. else
  466. ++init_ind;
  467. for (size_t i = init_ind; i > 0; --i)
  468. if (pStr[i - 1] == c)
  469. return static_cast<intptr_t>(i - 1);
  470. return -1;
  471. }
  472. // Create new object and trim size bytes from the left.
  473. StringDataPtr GetTrimLeft(size_t size) const
  474. {
  475. // Limit trim size to the size of the string.
  476. size = Alg::PMin(GetSize(), size);
  477. return StringDataPtr(ToCStr() + size, GetSize() - size);
  478. }
  479. // Create new object and trim size bytes from the right.
  480. StringDataPtr GetTrimRight(size_t size) const
  481. {
  482. // Limit trim to the size of the string.
  483. size = Alg::PMin(GetSize(), size);
  484. return StringDataPtr(ToCStr(), GetSize() - size);
  485. }
  486. // Create new object, which contains next token.
  487. // Useful for parsing.
  488. StringDataPtr GetNextToken(char separator = ':') const
  489. {
  490. size_t cur_pos = 0;
  491. const char* cur_str = ToCStr();
  492. for (; cur_pos < GetSize() && cur_str[cur_pos]; ++cur_pos)
  493. {
  494. if (cur_str[cur_pos] == separator)
  495. {
  496. break;
  497. }
  498. }
  499. return StringDataPtr(ToCStr(), cur_pos);
  500. }
  501. // Trim size bytes from the left.
  502. StringDataPtr& TrimLeft(size_t size)
  503. {
  504. // Limit trim size to the size of the string.
  505. size = Alg::PMin(GetSize(), size);
  506. pStr += size;
  507. Size -= size;
  508. return *this;
  509. }
  510. // Trim size bytes from the right.
  511. StringDataPtr& TrimRight(size_t size)
  512. {
  513. // Limit trim to the size of the string.
  514. size = Alg::PMin(GetSize(), size);
  515. Size -= size;
  516. return *this;
  517. }
  518. const char* Begin() const { return ToCStr(); }
  519. const char* End() const { return ToCStr() + GetSize(); }
  520. // Hash functor used string data pointers
  521. struct HashFunctor
  522. {
  523. size_t operator()(const StringDataPtr& data) const
  524. {
  525. return String::BernsteinHashFunction(data.ToCStr(), data.GetSize());
  526. }
  527. };
  528. bool operator== (const StringDataPtr& data) const
  529. {
  530. return (OVR_strncmp(pStr, data.pStr, data.Size) == 0);
  531. }
  532. protected:
  533. const char* pStr;
  534. size_t Size;
  535. };
  536. // Convert a UTF8 OVR::String object to a wchar_t UCS (Unicode) std::basic_string object.
  537. // The C++11 Standard Library has similar functionality, but it's not supported by earlier
  538. // versions of Visual Studio. To consider: Add support for this when available.
  539. // length is the strlen of pUTF8. If not specified then it is calculated automatically.
  540. // Returns an empty string in the case that the UTF8 is malformed.
  541. std::wstring UTF8StringToUCSString(const char* pUTF8, size_t length = (size_t)-1);
  542. std::wstring UTF8StringToUCSString(const std::string& sUTF8);
  543. std::wstring OVRStringToUCSString(const OVR::String& sOVRUTF8);
  544. // Convert a wchar_t UCS (Unicode) std::basic_string object to a UTF8 std::basic_string object.
  545. // The C++11 Standard Library has similar functionality, but it's not supported by earlier
  546. // versions of Visual Studio. To consider: Add support for this when available.
  547. // length is the strlen of pUCS. If not specified then it is calculated automatically.
  548. // Returns an empty string in the case that the UTF8 is malformed.
  549. std::string UCSStringToUTF8String(const wchar_t* pUCS, size_t length = (size_t)-1);
  550. std::string UCSStringToUTF8String(const std::wstring& sUCS);
  551. OVR::String UCSStringToOVRString(const wchar_t* pUCS, size_t length = (size_t)-1);
  552. OVR::String UCSStringToOVRString(const std::wstring& sUCS);
  553. } // OVR
  554. #endif