diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
commit | 469bbcf0701e1eb8a6670c23145b0da87357e178 (patch) | |
tree | b5b062a16e46a6c5d3410b4e574cd0cc09057211 /utf16.cpp | |
parent | ee1b79396076edc4e30aefb285fada03bb45e80d (diff) | |
download | libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2 libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip |
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to '')
-rw-r--r-- | utf16.cpp | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/utf16.cpp b/utf16.cpp deleted file mode 100644 index eedb521..0000000 --- a/utf16.cpp +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdint.h> | ||
3 | |||
4 | void bitprint( uint16_t u ) | ||
5 | { | ||
6 | for( int i = 15; i >= 0; i-- ) | ||
7 | printf("%c", (u&(1<<i))?'1':'0'); | ||
8 | printf("\n"); | ||
9 | } | ||
10 | |||
11 | void bitprint( uint32_t u ) | ||
12 | { | ||
13 | for( int i = 31; i >= 0; i-- ) | ||
14 | printf("%c", (u&(1<<i))?'1':'0'); | ||
15 | printf("\n"); | ||
16 | } | ||
17 | |||
18 | void utoutf16( uint32_t in, uint16_t &outHi, uint16_t &outLo ) | ||
19 | { | ||
20 | outHi = (((in-0x10000)>>10)&0x3FF)| 0xD800u; | ||
21 | outLo = ((in-0x10000)&0x3FF)| 0xDC00u; | ||
22 | printf("0x%X == 0x%X, 0x%X\n", in, outHi, outLo ); | ||
23 | } | ||
24 | |||
25 | int32_t utf16tou( uint16_t hi, uint16_t lo ) | ||
26 | { | ||
27 | return (((uint32_t)hi&0x3FF)<<10 | lo&0x3FF)+0x10000; | ||
28 | } | ||
29 | |||
30 | int main() | ||
31 | { | ||
32 | bitprint( 0xD800u ); | ||
33 | bitprint( 0xDC00u ); | ||
34 | uint16_t hi, lo; | ||
35 | utoutf16( 0x1D11E, hi, lo ); // Cat face with wry smile | ||
36 | utoutf16( 0x10FFFD, hi, lo ); // Cat face with wry smile | ||
37 | utoutf16( 0x1F63C, hi, lo ); // Cat face with wry smile | ||
38 | bitprint( hi ); | ||
39 | bitprint( lo ); | ||
40 | printf("0x%X\n", utf16tou( hi, lo ) ); | ||
41 | return 0; | ||
42 | } | ||