| 259 | |
| 260 | template<typename T> |
| 261 | char *TConvertToUTF8(const T *inStr, int *ioLen, hx::IStringAlloc *inBuffer,bool) |
| 262 | { |
| 263 | int len = 0; |
| 264 | int chars = 0; |
| 265 | if (ioLen==0 || *ioLen==0) |
| 266 | { |
| 267 | while(inStr[len]) |
| 268 | chars += UTF8Bytes(inStr[len++]); |
| 269 | } |
| 270 | else |
| 271 | { |
| 272 | len = *ioLen; |
| 273 | for(int i=0;i<len;i++) |
| 274 | chars += UTF8Bytes(inStr[i]); |
| 275 | } |
| 276 | |
| 277 | char *buf = inBuffer ? (char *)inBuffer->allocBytes(chars+1) : |
| 278 | (char *)NewGCPrivate(0,chars+1); |
| 279 | char *ptr = buf; |
| 280 | for(int i=0;i<len;i++) |
| 281 | UTF8EncodeAdvance(ptr,inStr[i]); |
| 282 | *ptr = 0; |
| 283 | if (ioLen) |
| 284 | *ioLen = chars; |
| 285 | |
| 286 | return buf; |
| 287 | } |
| 288 | |
| 289 | |
| 290 | template<> |
no test coverage detected