Unicode16String.st
author Stefan Vogel <sv@exept.de>
Wed, 12 Dec 2012 23:56:32 +0100
changeset 14558 b168e9f03911
parent 14124 27e2ee113f53
child 14605 90d502689de9
permissions -rw-r--r--
class: Unicode16String changed: #displayOn:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG 
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
10223
761e2a050b69 twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents: 9648
diff changeset
    12
"{ Package: 'stx:libbasic' }"
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
TwoByteString variableWordSubclass:#Unicode16String
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Collections-Text'
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!Unicode16String class methodsFor:'documentation'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 1997 by eXept Software AG 
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	      All Rights Reserved
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
10223
761e2a050b69 twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents: 9648
diff changeset
    41
    Represents 16-bit (2-byte) Unicode strings.
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
!Unicode16String class methodsFor:'initialization'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
initialize
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    "initialize the class - private"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
7949
421a3e216337 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7946
diff changeset
    50
    self flags:(Behavior flagWords).
421a3e216337 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7946
diff changeset
    51
421a3e216337 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7946
diff changeset
    52
    Smalltalk at:#UnicodeString put:Unicode16String.
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    "
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
     Unicode16String initialize
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    "
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    "Created: 30.6.1997 / 15:35:52 / cg"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    "Modified: 30.6.1997 / 15:39:21 / cg"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
14558
b168e9f03911 class: Unicode16String
Stefan Vogel <sv@exept.de>
parents: 14124
diff changeset
    62
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    63
!Unicode16String class methodsFor:'reading'!
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    64
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    65
readFrom:aStreamOrString onError:exceptionBlock
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    66
    "read & return the next String from the (character-)stream aStream;
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    67
     skipping all whitespace first; return the value of exceptionBlock,
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    68
     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
    69
     stream must be one as stored via storeOn: or storeString."
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    70
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    71
    "
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    72
     this method is not to be inherited
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    73
     (i.e. not ok for subclasses; Symbol, for example)
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    74
    "
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    75
    self ~~ Unicode16String ifTrue:[
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    76
        ^ super readFrom:aStreamOrString onError:exceptionBlock
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    77
    ].
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    78
    ^ self readSmalltalkStringFrom:aStreamOrString onError:exceptionBlock
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
    "
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
    81
        self readFrom:'abcäöü' storeString
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
! !
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
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
!Unicode16String methodsFor:'conversion'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
asSymbolIfInterned
9232
baa662ecbc01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8942
diff changeset
    89
    "If a symbol with the receivers characters is already known, return it. Otherwise, return nil. 
baa662ecbc01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8942
diff changeset
    90
     Because ST/X does not support non-8-bit symbols, this method
8942
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    91
     has been redefined to only return a symbol, if the receiver does NOT contain
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    92
     any non-8 bit characters."
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    93
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    |s|
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
14075
768e6530e9b5 changed: #asSymbolIfInterned
Stefan Vogel <sv@exept.de>
parents: 13989
diff changeset
    96
    [
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
        s := self asSingleByteString.
14075
768e6530e9b5 changed: #asSymbolIfInterned
Stefan Vogel <sv@exept.de>
parents: 13989
diff changeset
    98
    ] on:Error do:[:ex|
768e6530e9b5 changed: #asSymbolIfInterned
Stefan Vogel <sv@exept.de>
parents: 13989
diff changeset
    99
        ^ nil.
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    ].
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ^ s asSymbolIfInterned
14075
768e6530e9b5 changed: #asSymbolIfInterned
Stefan Vogel <sv@exept.de>
parents: 13989
diff changeset
   102
768e6530e9b5 changed: #asSymbolIfInterned
Stefan Vogel <sv@exept.de>
parents: 13989
diff changeset
   103
    "
768e6530e9b5 changed: #asSymbolIfInterned
Stefan Vogel <sv@exept.de>
parents: 13989
diff changeset
   104
     (Unicode16String with:(Character value:16rFFFF)) asSymbolIfInterned
768e6530e9b5 changed: #asSymbolIfInterned
Stefan Vogel <sv@exept.de>
parents: 13989
diff changeset
   105
     'new' asUnicodeString asSymbolIfInterned
768e6530e9b5 changed: #asSymbolIfInterned
Stefan Vogel <sv@exept.de>
parents: 13989
diff changeset
   106
    "
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
8294
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
   109
asUnicode16String
8942
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
   110
    "as the receiver already is a unicode-16 string, return it"
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
   111
8294
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
   112
    ^ self
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
   113
!
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
   114
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
asUnicodeString
8942
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
   116
    "as the receiver already is a unicode string, return it"
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
   117
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    ^ self
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
8049
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   121
!Unicode16String methodsFor:'printing & storing'!
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   122
14121
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   123
displayOn:aGCOrStream
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   124
    "display myself as on aStream.
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   125
     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
   126
14558
b168e9f03911 class: Unicode16String
Stefan Vogel <sv@exept.de>
parents: 14124
diff changeset
   127
    aGCOrStream isStream ifTrue:[
14121
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   128
        aGCOrStream
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   129
            nextPut:$';
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   130
            nextPutAllUnicode:self;
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   131
            nextPut:$'.
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   132
        ^ self
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   133
    ].
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   134
    ^ super displayOn:aGCOrStream
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   135
!
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   136
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   137
printOn:aStream
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   138
    "print the receiver on aStream. 
13986
c8b952d6139c comment/format in: #printOn:
Claus Gittinger <cg@exept.de>
parents: 13737
diff changeset
   139
     Let aStream decide how to represent this, whether utf8, ucs16, ..."
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   140
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   141
    aStream nextPutAllUnicode:self
13986
c8b952d6139c comment/format in: #printOn:
Claus Gittinger <cg@exept.de>
parents: 13737
diff changeset
   142
c8b952d6139c comment/format in: #printOn:
Claus Gittinger <cg@exept.de>
parents: 13737
diff changeset
   143
    "Modified (comment): / 25-01-2012 / 10:28:34 / cg"
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   144
!
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   145
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   146
storeOn:aStream
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   147
    "put the storeString of myself on aStream"
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   148
13737
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   149
    (self utf8Encoded storeOn:aStream).
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   150
    aStream nextPutAll:' utf8Decoded'.
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   151
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   152
"/    aStream nextPut:$'.
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   153
"/    (self includes:$') ifTrue:[
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   154
"/        self do:[:thisChar |
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   155
"/            (thisChar == $') ifTrue:[aStream nextPut:thisChar].
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   156
"/            aStream nextPutUnicode:thisChar
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   157
"/        ]
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   158
"/    ] ifFalse:[
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   159
"/        aStream nextPutAllUnicode:self
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   160
"/    ].
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   161
"/    aStream nextPut:$'
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   162
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   163
    "Modified: / 28-09-2011 / 16:17:38 / cg"
11323
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   164
!
c9ebe199a8fc Unicode handling:
Stefan Vogel <sv@exept.de>
parents: 11293
diff changeset
   165
8049
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   166
storeString
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   167
    "return a String for storing myself"
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   168
13737
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   169
"/    ^ self basicStoreString.
13989
cd15b3b6154a backward compatibility storestring
Claus Gittinger <cg@exept.de>
parents: 13988
diff changeset
   170
"/    ^ (self withCEscapes storeString),' withoutCEscapes'.
cd15b3b6154a backward compatibility storestring
Claus Gittinger <cg@exept.de>
parents: 13988
diff changeset
   171
    ^ (self utf8Encoded storeString),' utf8Decoded'.
13737
0873cbb1365d unicode storestring fixed
Claus Gittinger <cg@exept.de>
parents: 11323
diff changeset
   172
13989
cd15b3b6154a backward compatibility storestring
Claus Gittinger <cg@exept.de>
parents: 13988
diff changeset
   173
    "Modified: / 25-01-2012 / 11:59:34 / cg"
14124
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   174
!
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   175
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   176
unicodeStoreOn:aStream
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   177
    "put the storeString of myself on aStream"
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   178
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   179
    aStream nextPut:$'.
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   180
    (self includes:$') ifTrue:[
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   181
        self do:[:thisChar |
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   182
            (thisChar == $') ifTrue:[aStream nextPut:thisChar].
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   183
            aStream nextPutUnicode:thisChar
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   184
        ]
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   185
    ] ifFalse:[
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   186
        aStream nextPutAllUnicode:self
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   187
    ].
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   188
    aStream nextPut:$'
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   189
!
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   190
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   191
unicodeStoreString
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   192
    "return a UnicodeString for storing myself.
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   193
     This method is a kind of kludge.
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   194
     Use it when you want to write a storeString to an encoded Stream"
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   195
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   196
    ^ self basicStoreString.
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   197
! !
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   198
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   199
!Unicode16String methodsFor:'testing'!
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   200
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   201
isUnicode16String
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   202
    ^ true
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   203
!
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   204
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   205
isUnicodeString
Stefan Vogel <sv@exept.de>
parents: 14121
diff changeset
   206
    ^ true
8049
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   207
! !
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   208
14121
fea92d19d1a4 added: #displayOn: (instead of #displaySting)
Stefan Vogel <sv@exept.de>
parents: 14075
diff changeset
   209
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
!Unicode16String class methodsFor:'documentation'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
version
14558
b168e9f03911 class: Unicode16String
Stefan Vogel <sv@exept.de>
parents: 14124
diff changeset
   213
    ^ '$Header: /cvs/stx/stx/libbasic/Unicode16String.st,v 1.20 2012-12-12 22:56:32 stefan Exp $'
13988
81154d310967 use new c-escape string for stroreString
Claus Gittinger <cg@exept.de>
parents: 13986
diff changeset
   214
!
81154d310967 use new c-escape string for stroreString
Claus Gittinger <cg@exept.de>
parents: 13986
diff changeset
   215
81154d310967 use new c-escape string for stroreString
Claus Gittinger <cg@exept.de>
parents: 13986
diff changeset
   216
version_CVS
14558
b168e9f03911 class: Unicode16String
Stefan Vogel <sv@exept.de>
parents: 14124
diff changeset
   217
    ^ '$Header: /cvs/stx/stx/libbasic/Unicode16String.st,v 1.20 2012-12-12 22:56:32 stefan Exp $'
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
Unicode16String initialize!