CharacterEncoderImplementations__ISO10646_to_UTF16LE.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 10 Jun 2015 08:43:00 +0100
branchjv
changeset 18482 68a43e2b3e78
parent 18011 deb0c3355881
child 19227 5e949760a4e8
permissions -rw-r--r--
Merge
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)
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
9326
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    43
!
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    44
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    45
examples
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    46
"
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    47
  Encoding (unicode to utf16LE)
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    48
     ISO10646_to_UTF16LE encodeString:'hello'.
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    49
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    50
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    51
  Decoding (utf16LE to unicode):
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    52
     |t|
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    53
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    54
     t := ISO10646_to_UTF16LE encodeString:''.
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    55
     ISO10646_to_UTF16LE decodeString:t.
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    56
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    57
  Decoding (utf16LE-Bytes to unicode):
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    58
     |bytes|
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    59
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    60
     bytes := #[ 16r40 0 16r41 0 16r42 0 16r43 0 16r44 0 ].
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    61
     ISO10646_to_UTF16LE decodeString:bytes.
46b7df422c6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8903
diff changeset
    62
"
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
! !
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
14171
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    65
!ISO10646_to_UTF16LE methodsFor:'encoding & decoding'!
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    66
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    67
decode:codePoint
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    68
    ^ codePoint swapBytes
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    69
!
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    70
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    71
encode:codePoint
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    72
    ^ codePoint swapBytes
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    73
! !
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    74
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
!ISO10646_to_UTF16LE methodsFor:'private'!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
nextPutTwoByteValue:anInteger to:aStream
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    aStream nextPutShort:anInteger MSB:false
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
nextTwoByteValueFrom:aStream
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    ^ aStream nextUnsignedShortMSB:false
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
! !
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
!ISO10646_to_UTF16LE methodsFor:'queries'!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
nameOfEncoding
14171
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    88
    ^ #utf16le
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
!ISO10646_to_UTF16LE class methodsFor:'documentation'!
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
version
14171
Stefan Vogel <sv@exept.de>
parents: 9326
diff changeset
    94
    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__ISO10646_to_UTF16LE.st,v 1.3 2012-07-10 07:55:26 stefan Exp $'
8903
4e15c297fadc initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
! !