| 249 | |
| 250 | |
| 251 | string IntlUtil::convertUtf16ToAscii(const string& utf16, bool* error) |
| 252 | { |
| 253 | fb_assert(utf16.length() % sizeof(USHORT) == 0); |
| 254 | |
| 255 | string s; |
| 256 | const USHORT* end = (const USHORT*) (utf16.c_str() + utf16.length()); |
| 257 | |
| 258 | for (const USHORT* p = (const USHORT*) utf16.c_str(); p < end; ++p) |
| 259 | { |
| 260 | if (*p <= 0xFF) |
| 261 | s.append(1, (UCHAR) *p); |
| 262 | else |
| 263 | { |
| 264 | *error = true; |
| 265 | return ""; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | *error = false; |
| 270 | |
| 271 | return s; |
| 272 | } |
| 273 | |
| 274 | |
| 275 | ULONG IntlUtil::cvtAsciiToUtf16(csconvert* obj, ULONG nSrc, const UCHAR* pSrc, |