Unicode16String.st
author Claus Gittinger <cg@exept.de>
Wed, 22 Oct 2008 08:42:16 +0200
changeset 11265 dd57cc0a379b
parent 10223 761e2a050b69
child 11293 4b08b41f0488
permissions -rw-r--r--
comment
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
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
10223
761e2a050b69 twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents: 9648
diff changeset
    15
"{ Package: 'stx:libbasic' }"
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
TwoByteString variableWordSubclass:#Unicode16String
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	instanceVariableNames:''
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:''
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	category:'Collections-Text'
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!Unicode16String class methodsFor:'documentation'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
copyright
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 COPYRIGHT (c) 1997 by eXept Software AG 
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
	      All Rights Reserved
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 This software is furnished under a license and may be used
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 only in accordance with the terms of that license and with the
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 be provided or otherwise made available to, or used by, any
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 other person.  No title to or ownership of the software is
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 hereby transferred.
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
"
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
documentation
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
10223
761e2a050b69 twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents: 9648
diff changeset
    44
    Represents 16-bit (2-byte) Unicode strings.
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
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
!Unicode16String class methodsFor:'initialization'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
initialize
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    "initialize the class - private"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
7949
421a3e216337 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7946
diff changeset
    53
    self flags:(Behavior flagWords).
421a3e216337 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7946
diff changeset
    54
421a3e216337 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7946
diff changeset
    55
    Smalltalk at:#UnicodeString put:Unicode16String.
7946
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
     Unicode16String initialize
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    "
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    "Created: 30.6.1997 / 15:35:52 / cg"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    "Modified: 30.6.1997 / 15:39:21 / cg"
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
8407
f3a5a24b8fec juergen gmeiners bug fix for bug #69
Claus Gittinger <cg@exept.de>
parents: 8294
diff changeset
    65
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
!Unicode16String methodsFor:'conversion'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
asSymbolIfInterned
9232
baa662ecbc01 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8942
diff changeset
    69
    "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
    70
     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
    71
     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
    72
     any non-8 bit characters."
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    73
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    |s|
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    Error catch:[
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
        s := self asSingleByteString.
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    ].
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    s isNil ifTrue:[^ s].
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    ^ s asSymbolIfInterned
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
8294
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
    83
asUnicode16String
8942
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    84
    "as the receiver already is a unicode-16 string, return it"
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    85
8294
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
    86
    ^ self
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
    87
!
ba5f4421848f Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents: 8049
diff changeset
    88
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
asUnicodeString
8942
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    90
    "as the receiver already is a unicode string, return it"
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    91
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    ^ self
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
printOn:aStream
8942
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    96
    "print the receiver utf-8 encoded on aStream"
41d4d78ceb65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8407
diff changeset
    97
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    self utf8EncodedOn:aStream
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
8049
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   101
!Unicode16String methodsFor:'printing & storing'!
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   102
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   103
storeString
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   104
    "return a String for storing myself"
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   105
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   106
    ^ self basicStoreString.
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   107
! !
ccd0e8f26439 printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents: 7982
diff changeset
   108
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
!Unicode16String class methodsFor:'documentation'!
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
version
10223
761e2a050b69 twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents: 9648
diff changeset
   112
    ^ '$Header: /cvs/stx/stx/libbasic/Unicode16String.st,v 1.10 2006-12-06 14:12:10 cg Exp $'
7946
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
! !
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
469d2d1c61f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
Unicode16String initialize!