eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Unicode16String':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Unicode16String


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--UninterpretedBytes
               |
               +--CharacterArray
                  |
                  +--TwoByteString
                     |
                     +--Unicode16String

Package:
stx:libbasic
Category:
Collections-Text
Version:
rev: 1.39 date: 2024/02/18 08:16:32
user: cg
file: Unicode16String.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


Represents 16-bit (2-byte) Unicode strings.

copyright

COPYRIGHT (c) 1997 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

initialization
o  initialize
initialize the class - private

Usage example(s):

     Unicode16String initialize

reading
o  readFrom: aStreamOrString onError: exceptionBlock
read & return the next String from the (character-)stream aStream;
skipping all whitespace first; return the value of exceptionBlock,
if no string can be read. The sequence of characters as read from the
stream must be one as stored via storeOn: or storeString.

Usage example(s):

        self readFrom:'abcäöü' storeString


Instance protocol:

conversion
o  asUnicode16String
as the receiver already is a unicode-16 string, return it

o  asUnicodeString
as the receiver already is a unicode string, return it

encoding
o  utf16Encoded
answer a Unicode16String, where characters out of the UTF-16 range are encoded
as two 16-bit values.
Have to encode only if there are characters that are outside the UTF-16 range

Usage example(s):

        ((Unicode16String new:1) at:1 put:16rD800; yourself) utf16Encoded
        ((Unicode16String new:1) at:1 put:16r2A00; yourself) utf16Encoded

o  utf8Encoded
tuned version of the inherited encoder;
this is so heavily used, that it is worth a primitive

printing & storing
o  displayOn: aGCOrStream
display myself as on aStream.
You must use an ISO10646 unicode font to display this string

o  printOn: aStream
print the receiver on aStream.
Let aStream decide how to represent this, whether UTF-8, UTF-16, ...

Usage example(s):

      'Hällo здраво' asUnicode16String printOn:'' writeStream inspect.

o  storeOn: aStream
put the storeString of myself on aStream.
Convert it to something that can be written to a plain ASCII file.
Use #unicodeStoreOn: if you want to use the result internally,
especially when writing to an EncodedStream.

Usage example(s):

        String streamContents:[:s|
            'hello' asUnicode16String storeOn:s
        ].

        String streamContents:[:s|
            'hello -öäüßщ' asUnicode16String storeOn:s
        ].

o  storeString
return a String for storing myself-
Convert it to something that can be written to a plain ASCII file.
Use #unicodeStoreString if you want to use the result internally,
especially when writing to an EncodedStream.

Usage example(s):

        'hello' asUnicodeString storeString
        'hello -öäüß' storeString
        'hello öäüßщ' storeString
        'hello öäüßщ' unicodeStoreString

testing
o  isLiteral
return true, if the receiver can be used as a literal constant in ST syntax
(i.e. can be used in constant arrays)

o  isUnicode16String

o  isUnicodeString
true if this is a 2- or 4-byte unicode string
(i.e. not a single byte string).
Notice, that the name is misleading:
all strings use unicode encoding



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 08:26:28 GMT