8903
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2005 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libbasic' }"
|
|
13 |
|
|
14 |
"{ NameSpace: CharacterEncoderImplementations }"
|
|
15 |
|
|
16 |
ISO10646_to_UTF16BE subclass:#ISO10646_to_UTF16LE
|
|
17 |
instanceVariableNames:''
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Collections-Text-Encodings'
|
|
21 |
!
|
|
22 |
|
|
23 |
!ISO10646_to_UTF16LE class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 2005 by eXept Software AG
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
!
|
|
38 |
|
|
39 |
documentation
|
|
40 |
"
|
|
41 |
encodes/decodes UTF16 LittleEndian (little-end-first)
|
21302
|
42 |
|
|
43 |
Notice the naming (many are confused):
|
|
44 |
Unicode is the set of number-to-glyph assignments
|
|
45 |
whereas:
|
|
46 |
UTF8, UTF16 etc. are a concrete way of xmitting Unicode codePoints (numbers).
|
|
47 |
|
|
48 |
ST/X NEVER uses UTF8 or UTF16 internally - all characters are full 24bit characters.
|
|
49 |
Only when exchanging data, are these converted into UTF8 (or other) byte sequences.
|
8903
|
50 |
"
|
9326
|
51 |
!
|
|
52 |
|
|
53 |
examples
|
|
54 |
"
|
|
55 |
Encoding (unicode to utf16LE)
|
|
56 |
ISO10646_to_UTF16LE encodeString:'hello'.
|
|
57 |
|
|
58 |
|
|
59 |
Decoding (utf16LE to unicode):
|
|
60 |
|t|
|
|
61 |
|
|
62 |
t := ISO10646_to_UTF16LE encodeString:''.
|
|
63 |
ISO10646_to_UTF16LE decodeString:t.
|
|
64 |
|
|
65 |
Decoding (utf16LE-Bytes to unicode):
|
|
66 |
|bytes|
|
|
67 |
|
|
68 |
bytes := #[ 16r40 0 16r41 0 16r42 0 16r43 0 16r44 0 ].
|
|
69 |
ISO10646_to_UTF16LE decodeString:bytes.
|
|
70 |
"
|
8903
|
71 |
! !
|
|
72 |
|
14171
|
73 |
!ISO10646_to_UTF16LE methodsFor:'encoding & decoding'!
|
|
74 |
|
|
75 |
decode:codePoint
|
|
76 |
^ codePoint swapBytes
|
|
77 |
!
|
|
78 |
|
|
79 |
encode:codePoint
|
|
80 |
^ codePoint swapBytes
|
|
81 |
! !
|
|
82 |
|
8903
|
83 |
!ISO10646_to_UTF16LE methodsFor:'private'!
|
|
84 |
|
|
85 |
nextPutTwoByteValue:anInteger to:aStream
|
19620
|
86 |
aStream nextPutInt16LSB:anInteger
|
8903
|
87 |
!
|
|
88 |
|
|
89 |
nextTwoByteValueFrom:aStream
|
19216
|
90 |
^ aStream nextUnsignedInt16MSB:false
|
8903
|
91 |
! !
|
|
92 |
|
|
93 |
!ISO10646_to_UTF16LE methodsFor:'queries'!
|
|
94 |
|
|
95 |
nameOfEncoding
|
14171
|
96 |
^ #utf16le
|
8903
|
97 |
! !
|
|
98 |
|
|
99 |
!ISO10646_to_UTF16LE class methodsFor:'documentation'!
|
|
100 |
|
|
101 |
version
|
19216
|
102 |
^ '$Header$'
|
8903
|
103 |
! !
|
19216
|
104 |
|