| 3076 | |
| 3077 | template <class SI_CHAR> |
| 3078 | inline bool AppendCodePoint(char32_t a_cp, SI_CHAR *&a_dst, SI_CHAR *a_dstEnd) { |
| 3079 | if (sizeof(SI_CHAR) >= sizeof(char32_t)) { |
| 3080 | if (a_dst >= a_dstEnd) |
| 3081 | return false; |
| 3082 | *a_dst++ = (SI_CHAR)a_cp; |
| 3083 | return true; |
| 3084 | } |
| 3085 | if (sizeof(SI_CHAR) == 2) { |
| 3086 | if (a_cp < 0x10000) { |
| 3087 | if (a_dst >= a_dstEnd) |
| 3088 | return false; |
| 3089 | *a_dst++ = (SI_CHAR)a_cp; |
| 3090 | return true; |
| 3091 | } |
| 3092 | if (a_dst + 1 >= a_dstEnd) |
| 3093 | return false; |
| 3094 | a_cp -= 0x10000; |
| 3095 | *a_dst++ = (SI_CHAR)(0xD800 + (a_cp >> 10)); |
| 3096 | *a_dst++ = (SI_CHAR)(0xDC00 + (a_cp & 0x3FF)); |
| 3097 | return true; |
| 3098 | } |
| 3099 | return false; |
| 3100 | } |
| 3101 | |
| 3102 | template <class SI_CHAR> |
| 3103 | inline bool ReadCodePoint(const SI_CHAR *&a_src, char32_t &a_cp) { |