diff options
author | Jacek Antonelli | 2008-08-15 23:44:59 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:59 -0500 |
commit | a408bac29378072fbf36864164149458c978cfcc (patch) | |
tree | 67feccf1a5d3816611ba48d6762f86f0f7f4b1f6 /linden/indra/llwindow/llwindow.cpp | |
parent | Second Life viewer sources 1.17.0.12 (diff) | |
download | meta-impy-a408bac29378072fbf36864164149458c978cfcc.zip meta-impy-a408bac29378072fbf36864164149458c978cfcc.tar.gz meta-impy-a408bac29378072fbf36864164149458c978cfcc.tar.bz2 meta-impy-a408bac29378072fbf36864164149458c978cfcc.tar.xz |
Second Life viewer sources 1.17.1.0
Diffstat (limited to 'linden/indra/llwindow/llwindow.cpp')
-rw-r--r-- | linden/indra/llwindow/llwindow.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/linden/indra/llwindow/llwindow.cpp b/linden/indra/llwindow/llwindow.cpp index cad1dc4..faa5e61 100644 --- a/linden/indra/llwindow/llwindow.cpp +++ b/linden/indra/llwindow/llwindow.cpp | |||
@@ -241,7 +241,8 @@ LLWindow::LLWindow(BOOL fullscreen, U32 flags) | |||
241 | mIsMouseClipping(FALSE), | 241 | mIsMouseClipping(FALSE), |
242 | mSwapMethod(SWAP_METHOD_UNDEFINED), | 242 | mSwapMethod(SWAP_METHOD_UNDEFINED), |
243 | mHideCursorPermanent(FALSE), | 243 | mHideCursorPermanent(FALSE), |
244 | mFlags(flags) | 244 | mFlags(flags), |
245 | mHighSurrogate(0) | ||
245 | { | 246 | { |
246 | for (U32 i = 0; i < 6; i++) | 247 | for (U32 i = 0; i < 6; i++) |
247 | { | 248 | { |
@@ -296,6 +297,53 @@ void LLWindow::setCallbacks(LLWindowCallbacks *callbacks) | |||
296 | } | 297 | } |
297 | } | 298 | } |
298 | 299 | ||
300 | #define UTF16_IS_HIGH_SURROGATE(U) ((U16)((U) - 0xD800) < 0x0400) | ||
301 | #define UTF16_IS_LOW_SURROGATE(U) ((U16)((U) - 0xDC00) < 0x0400) | ||
302 | #define UTF16_SURROGATE_PAIR_TO_UTF32(H,L) (((H) << 10) + (L) - (0xD800 << 10) - 0xDC00 + 0x00010000) | ||
303 | |||
304 | void LLWindow::handleUnicodeUTF16(U16 utf16, MASK mask) | ||
305 | { | ||
306 | // Note that we could discard unpaired surrogates, but I'm | ||
307 | // following the Unicode Consortium's recommendation here; | ||
308 | // that is, to preserve those unpaired surrogates in UTF-32 | ||
309 | // values. _To_preserve_ means to pass to the callback in our | ||
310 | // context. | ||
311 | |||
312 | if (mHighSurrogate == 0) | ||
313 | { | ||
314 | if (UTF16_IS_HIGH_SURROGATE(utf16)) | ||
315 | { | ||
316 | mHighSurrogate = utf16; | ||
317 | } | ||
318 | else | ||
319 | { | ||
320 | mCallbacks->handleUnicodeChar(utf16, mask); | ||
321 | } | ||
322 | } | ||
323 | else | ||
324 | { | ||
325 | if (UTF16_IS_LOW_SURROGATE(utf16)) | ||
326 | { | ||
327 | /* A legal surrogate pair. */ | ||
328 | mCallbacks->handleUnicodeChar(UTF16_SURROGATE_PAIR_TO_UTF32(mHighSurrogate, utf16), mask); | ||
329 | mHighSurrogate = 0; | ||
330 | } | ||
331 | else if (UTF16_IS_HIGH_SURROGATE(utf16)) | ||
332 | { | ||
333 | /* Two consecutive high surrogates. */ | ||
334 | mCallbacks->handleUnicodeChar(mHighSurrogate, mask); | ||
335 | mHighSurrogate = utf16; | ||
336 | } | ||
337 | else | ||
338 | { | ||
339 | /* A non-low-surrogate preceeded by a high surrogate. */ | ||
340 | mCallbacks->handleUnicodeChar(mHighSurrogate, mask); | ||
341 | mHighSurrogate = 0; | ||
342 | mCallbacks->handleUnicodeChar(utf16, mask); | ||
343 | } | ||
344 | } | ||
345 | } | ||
346 | |||
299 | // | 347 | // |
300 | // LLSplashScreen | 348 | // LLSplashScreen |
301 | // | 349 | // |