Unicode16String.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 20:55:17 +0200
changeset 24417 03b083548da2
parent 24213 27b3a816dfed
child 24940 476e387608cf
permissions -rw-r--r--
#REFACTORING by exept class: Smalltalk class changed: #recursiveInstallAutoloadedClassesFrom:rememberIn:maxLevels:noAutoload:packageTop:showSplashInLevels: Transcript showCR:(... bindWith:...) -> Transcript showCR:... with:...
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24213
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
     1
"{ Encoding: utf8 }"
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
     2
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 1997 by eXept Software AG 
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	      All Rights Reserved
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
10223
761e2a050b69 twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents: 9648
diff changeset
    14
"{ Package: 'stx:libbasic' }"
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
17537
6ed63b021903 class: Unicode16String
Claus Gittinger <cg@exept.de>
parents: 17182
diff changeset
    16
"{ NameSpace: Smalltalk }"
6ed63b021903 class: Unicode16String
Claus Gittinger <cg@exept.de>
parents: 17182
diff changeset
    17
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
TwoByteString variableWordSubclass:#Unicode16String
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Collections-Text'
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!Unicode16String class methodsFor:'documentation'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 1997 by eXept Software AG 
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
	      All Rights Reserved
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
documentation
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
"
10223
761e2a050b69 twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents: 9648
diff changeset
    45
    Represents 16-bit (2-byte) Unicode strings.
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
!Unicode16String class methodsFor:'initialization'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
initialize
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    "initialize the class - private"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
7949
421a3e216337 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7946
diff changeset
    54
    self flags:(Behavior flagWords).
421a3e216337 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7946
diff changeset
    55
421a3e216337 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7946
diff changeset
    56
    Smalltalk at:#UnicodeString put:Unicode16String.
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    "
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
     Unicode16String initialize
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    "
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    "Created: 30.6.1997 / 15:35:52 / cg"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    "Modified: 30.6.1997 / 15:39:21 / cg"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
21544
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
    66
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
    67
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    68
!Unicode16String class methodsFor:'reading'!
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    69
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    70
readFrom:aStreamOrString onError:exceptionBlock
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    71
    "read & return the next String from the (character-)stream aStream;
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    72
     skipping all whitespace first; return the value of exceptionBlock,
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    73
     if no string can be read. The sequence of characters as read from the
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    74
     stream must be one as stored via storeOn: or storeString."
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    75
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    76
    "
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    77
     this method is not to be inherited
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    78
     (i.e. not ok for subclasses; Symbol, for example)
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    79
    "
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    80
    self ~~ Unicode16String ifTrue:[
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    81
        ^ super readFrom:aStreamOrString onError:exceptionBlock
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    82
    ].
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    83
    ^ self readSmalltalkStringFrom:aStreamOrString onError:exceptionBlock
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    84
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    85
    "
24213
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
    86
        self readFrom:'abcäöü' storeString
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    87
    "
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    88
! !
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    89
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    90
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
!Unicode16String methodsFor:'conversion'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
8294
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
    93
asUnicode16String
8942
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    94
    "as the receiver already is a unicode-16 string, return it"
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    95
8294
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
    96
    ^ self
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
    97
!
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
    98
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
asUnicodeString
8942
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
   100
    "as the receiver already is a unicode string, return it"
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
   101
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    ^ self
24213
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   103
!
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   104
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   105
utf16Encoded
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   106
    "have to encode only if there are characters that are outside the UTF-16 range"
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   107
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   108
    |sz "{Class:SmallInteger}" codePoint "{Class:SmallInteger}"|
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   109
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   110
    sz := self size.
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   111
    1 to:sz do:[:eachIdx|
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   112
        codePoint := self basicAt:eachIdx.
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   113
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   114
        (codePoint >= 16rD800 and:[codePoint <= 16rDFFF]) ifTrue:[
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   115
            ^ super utf16Encoded.
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   116
        ].
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   117
    ].
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   118
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   119
    "all my characters are in the UTF-16 range"
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   120
    ^ self
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   121
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   122
    "
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   123
        ((Unicode16String new:1) at:1 put:16rD800; yourself) utf16Encoded
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   124
        ((Unicode16String new:1) at:1 put:16r2A00; yourself) utf16Encoded
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   125
    "
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   126
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   127
    "Created: / 28-05-2019 / 13:14:32 / Stefan Vogel"
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   128
    "Modified (comment): / 28-05-2019 / 14:45:01 / Stefan Vogel"
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
8049
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   131
!Unicode16String methodsFor:'printing & storing'!
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   132
14121
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   133
displayOn:aGCOrStream
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   134
    "display myself as on aStream.
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   135
     You must use an ISO10646 unicode font to display this string"
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   136
17537
6ed63b021903 class: Unicode16String
Claus Gittinger <cg@exept.de>
parents: 17182
diff changeset
   137
    "/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
21544
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   138
    "/ old ST80 means: draw-yourself on a GC.
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   139
    aGCOrStream isStream ifFalse:[
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   140
        ^ super displayOn:aGCOrStream
14121
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   141
    ].
21544
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   142
    
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   143
    aGCOrStream
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   144
        nextPut:$';
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   145
        nextPutAllUnicode:self;
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   146
        nextPut:$'.
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   147
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   148
    "Modified: / 22-02-2017 / 16:56:32 / cg"
14121
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   149
!
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   150
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   151
printOn:aStream
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   152
    "print the receiver on aStream. 
13986
c8b952d6139c comment/format in: #printOn:
Claus Gittinger <cg@exept.de>
parents: 13737
diff changeset
   153
     Let aStream decide how to represent this, whether utf8, ucs16, ..."
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   154
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   155
    aStream nextPutAllUnicode:self
13986
c8b952d6139c comment/format in: #printOn:
Claus Gittinger <cg@exept.de>
parents: 13737
diff changeset
   156
c8b952d6139c comment/format in: #printOn:
Claus Gittinger <cg@exept.de>
parents: 13737
diff changeset
   157
    "Modified (comment): / 25-01-2012 / 10:28:34 / cg"
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   158
!
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   159
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   160
storeOn:aStream
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   161
    "put the storeString of myself on aStream"
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   162
18970
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   163
    self containsNon7BitAscii ifTrue:[
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   164
        "non-7bit string has been utf8Encoded"
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   165
        self utf8Encoded storeOn:aStream.
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   166
        aStream nextPutAll:' utf8Decoded'.
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   167
    ] ifFalse:[
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   168
        self asSingleByteString storeOn:aStream.
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   169
    ].
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   170
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   171
    "
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   172
        String streamContents:[:s|
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   173
            'hello' asUnicodeString storeOn:s
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   174
        ].
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   175
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   176
        String streamContents:[:s|
24213
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   177
            'hello -öäüß' asUnicodeString storeOn:s
18970
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   178
        ].
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   179
    "
13737
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   180
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   181
"/    aStream nextPut:$'.
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   182
"/    (self includes:$') ifTrue:[
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   183
"/        self do:[:thisChar |
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   184
"/            (thisChar == $') ifTrue:[aStream nextPut:thisChar].
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   185
"/            aStream nextPutUnicode:thisChar
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   186
"/        ]
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   187
"/    ] ifFalse:[
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   188
"/        aStream nextPutAllUnicode:self
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   189
"/    ].
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   190
"/    aStream nextPut:$'
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   191
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   192
    "Modified: / 28-09-2011 / 16:17:38 / cg"
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   193
!
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   194
8049
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   195
storeString
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   196
    "return a String for storing myself"
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   197
18970
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   198
    self containsNon7BitAscii ifTrue:[
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   199
        "non-7bit string has been utf8Encoded"
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   200
        ^ (self utf8Encoded storeString),' utf8Decoded'.
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   201
    ] ifFalse:[
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   202
        ^ self asSingleByteString storeString.
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   203
    ].
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   204
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   205
    "
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   206
        'hello' asUnicodeString storeString
24213
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   207
        'hello -öäüß' storeString
27b3a816dfed #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 21544
diff changeset
   208
        'hello -öäüß' asUnicodeString storeString
18970
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   209
    "
13737
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   210
13989
cd15b3b6154a backward compatibility storestring
Claus Gittinger <cg@exept.de>
parents: 13988
diff changeset
   211
    "Modified: / 25-01-2012 / 11:59:34 / cg"
14124
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   212
!
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   213
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   214
unicodeStoreOn:aStream
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   215
    "put the storeString of myself on aStream"
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   216
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   217
    aStream nextPut:$'.
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   218
    (self includes:$') ifTrue:[
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   219
        self do:[:thisChar |
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   220
            (thisChar == $') ifTrue:[aStream nextPut:thisChar].
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   221
            aStream nextPutUnicode:thisChar
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   222
        ]
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   223
    ] ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   224
        aStream nextPutAllUnicode:self
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   225
    ].
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   226
    aStream nextPut:$'
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   227
!
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   228
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   229
unicodeStoreString
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   230
    "return a UnicodeString for storing myself.
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   231
     This method is a kind of kludge.
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   232
     Use it when you want to write a storeString to an encoded Stream"
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   233
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   234
    ^ self basicStoreString.
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   235
! !
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   236
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   237
!Unicode16String methodsFor:'testing'!
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   238
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   239
isUnicode16String
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   240
    ^ true
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   241
!
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   242
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   243
isUnicodeString
19937
48031fe6896b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19218
diff changeset
   244
    "true if this is a 2- or 4-byte unicode string
48031fe6896b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19218
diff changeset
   245
     (i.e. not a single byte string).
48031fe6896b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19218
diff changeset
   246
     Notice, that the name is misleading: 
48031fe6896b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19218
diff changeset
   247
     all strings are use unicode encoding"
48031fe6896b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 19218
diff changeset
   248
14124
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   249
    ^ true
8049
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   250
! !
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   251
21544
d16e66fc4339 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 19937
diff changeset
   252
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
!Unicode16String class methodsFor:'documentation'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
version
18970
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   256
    ^ '$Header$'
13988
81154d310967 use new c-escape string for stroreString
Claus Gittinger <cg@exept.de>
parents: 13986
diff changeset
   257
!
81154d310967 use new c-escape string for stroreString
Claus Gittinger <cg@exept.de>
parents: 13986
diff changeset
   258
81154d310967 use new c-escape string for stroreString
Claus Gittinger <cg@exept.de>
parents: 13986
diff changeset
   259
version_CVS
18970
f4c3afd137e3 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17537
diff changeset
   260
    ^ '$Header$'
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
14605
90d502689de9 class: Unicode16String
Stefan Vogel <sv@exept.de>
parents: 14558
diff changeset
   263
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
Unicode16String initialize!