CharacterEncoderImplementations__ISO10646_to_UTF16LE.st
author Patrik Svestka <patrik.svestka@gmail.com>
Tue, 09 Apr 2019 11:34:04 +0200
branchjv
changeset 24093 0f94f6c8c9d4
parent 21387 e3865533e6a6
permissions -rw-r--r--
Issue #269: Renaming a registry subKey via RegRenameKey() or if it fails via NtRenameKey()
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2005 by eXept Software AG
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ NameSpace: CharacterEncoderImplementations }"
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
ISO10646_to_UTF16BE subclass:#ISO10646_to_UTF16LE
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Collections-Text-Encodings'
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!ISO10646_to_UTF16LE class methodsFor:'documentation'!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
copyright
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
"
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 COPYRIGHT (c) 2005 by eXept Software AG
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
              All Rights Reserved
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    encodes/decodes UTF16 LittleEndian (little-end-first)
21302
fbc3e8da3733 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19620
diff changeset
    42
fbc3e8da3733 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19620
diff changeset
    43
    Notice the naming (many are confused):
fbc3e8da3733 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19620
diff changeset
    44
        Unicode is the set of number-to-glyph assignments
fbc3e8da3733 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19620
diff changeset
    45
    whereas:
fbc3e8da3733 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19620
diff changeset
    46
        UTF8, UTF16 etc. are a concrete way of xmitting Unicode codePoints (numbers).
fbc3e8da3733 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19620
diff changeset
    47
fbc3e8da3733 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19620
diff changeset
    48
    ST/X NEVER uses UTF8 or UTF16 internally - all characters are full 24bit characters.
fbc3e8da3733 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19620
diff changeset
    49
    Only when exchanging data, are these converted into UTF8 (or other) byte sequences.
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
"
9326
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    51
!
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    52
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    53
examples
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    54
"
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    55
  Encoding (unicode to utf16LE)
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    56
     ISO10646_to_UTF16LE encodeString:'hello'.
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    57
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    58
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    59
  Decoding (utf16LE to unicode):
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    60
     |t|
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    61
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    62
     t := ISO10646_to_UTF16LE encodeString:''.
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    63
     ISO10646_to_UTF16LE decodeString:t.
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    64
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    65
  Decoding (utf16LE-Bytes to unicode):
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    66
     |bytes|
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    67
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    68
     bytes := #[ 16r40 0 16r41 0 16r42 0 16r43 0 16r44 0 ].
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    69
     ISO10646_to_UTF16LE decodeString:bytes.
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    70
"
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
! !
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
14171
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    73
!ISO10646_to_UTF16LE methodsFor:'encoding & decoding'!
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    74
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    75
decode:codePoint
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    76
    ^ codePoint swapBytes
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    77
!
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    78
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    79
encode:codePoint
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    80
    ^ codePoint swapBytes
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    81
! !
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    82
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
!ISO10646_to_UTF16LE methodsFor:'private'!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
nextPutTwoByteValue:anInteger to:aStream
19620
30541e739c68 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 19216
diff changeset
    86
    aStream nextPutInt16LSB:anInteger
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
nextTwoByteValueFrom:aStream
19216
d1325e650883 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 14171
diff changeset
    90
    ^ aStream nextUnsignedInt16MSB:false
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
! !
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
!ISO10646_to_UTF16LE methodsFor:'queries'!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
nameOfEncoding
14171
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    96
    ^ #utf16le
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
! !
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
!ISO10646_to_UTF16LE class methodsFor:'documentation'!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
version
19216
d1325e650883 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 14171
diff changeset
   102
    ^ '$Header$'
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
! !
19216
d1325e650883 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 14171
diff changeset
   104