----------------------------------------------------------------------------- Functions that convert buffers of unicode code points -----------------------------------------------------------------------------
| 247 | // Functions that convert buffers of unicode code points |
| 248 | //----------------------------------------------------------------------------- |
| 249 | UTF16* createUTF16string( const UTF8* unistring) |
| 250 | { |
| 251 | PROFILE_SCOPE(createUTF16string); |
| 252 | |
| 253 | // allocate plenty of memory. |
| 254 | U32 nCodepoints, len = dStrlen(unistring) + 1; |
| 255 | FrameTemp<UTF16> buf(len); |
| 256 | |
| 257 | // perform conversion |
| 258 | nCodepoints = convertUTF8toUTF16N( unistring, buf, len); |
| 259 | |
| 260 | // add 1 for the NULL terminator the converter promises it included. |
| 261 | nCodepoints++; |
| 262 | |
| 263 | // allocate the return buffer, copy over, and return it. |
| 264 | UTF16 *ret = new UTF16[nCodepoints]; |
| 265 | dMemcpy(ret, buf, nCodepoints * sizeof(UTF16)); |
| 266 | |
| 267 | return ret; |
| 268 | } |
| 269 | |
| 270 | //----------------------------------------------------------------------------- |
| 271 | UTF8* createUTF8string( const UTF16* unistring) |