-----------------------------------------------------------------------------
| 269 | |
| 270 | //----------------------------------------------------------------------------- |
| 271 | UTF8* createUTF8string( const UTF16* unistring) |
| 272 | { |
| 273 | PROFILE_SCOPE(createUTF8string); |
| 274 | |
| 275 | // allocate plenty of memory. |
| 276 | U32 nCodeunits, len = dStrlen(unistring) * 3 + 1; |
| 277 | FrameTemp<UTF8> buf(len); |
| 278 | |
| 279 | // perform conversion |
| 280 | nCodeunits = convertUTF16toUTF8N( unistring, buf, len); |
| 281 | |
| 282 | // add 1 for the NULL terminator the converter promises it included. |
| 283 | nCodeunits++; |
| 284 | |
| 285 | // allocate the return buffer, copy over, and return it. |
| 286 | UTF8 *ret = new UTF8[nCodeunits]; |
| 287 | dMemcpy(ret, buf, nCodeunits * sizeof(UTF8)); |
| 288 | |
| 289 | return ret; |
| 290 | } |
| 291 | |
| 292 | //----------------------------------------------------------------------------- |
| 293 |
no test coverage detected