CharacterEncoderImplementations__JIS0208_to_SJIS.st
author Patrik Svestka <patrik.svestka@gmail.com>
Tue, 09 Apr 2019 11:34:04 +0200
branchjv
changeset 24093 0f94f6c8c9d4
parent 23547 c69c97cec351
permissions -rw-r--r--
Issue #269: Renaming a registry subKey via RegRenameKey() or if it fails via NtRenameKey()
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18241
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2004 by eXept Software AG
23107
40173e082cbc Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18261
diff changeset
     3
 COPYRIGHT (c) 2009 Jan Vrany
18241
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
              All Rights Reserved
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 This software is furnished under a license and may be used
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 only in accordance with the terms of that license and with the
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 be provided or otherwise made available to, or used by, any
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 other person.  No title to or ownership of the software is
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 hereby transferred.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libbasic' }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
"{ NameSpace: CharacterEncoderImplementations }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
TwoByteEncoder subclass:#JIS0208_to_SJIS
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	instanceVariableNames:''
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:''
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	category:'Collections-Text-Encodings'
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!JIS0208_to_SJIS class methodsFor:'documentation'!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
copyright
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 COPYRIGHT (c) 2004 by eXept Software AG
23107
40173e082cbc Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18261
diff changeset
    29
 COPYRIGHT (c) 2009 Jan Vrany
18241
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
              All Rights Reserved
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
! !
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
!JIS0208_to_SJIS class methodsFor:'mapping'!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
mapFileURL1_relativePathName
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    ^ 'OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT'
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
! !
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
!JIS0208_to_SJIS class methodsFor:'queries'!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
nameOfDecodedCode
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    "I encode sjis into jis"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    ^ #'jis0208'
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
! !
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
!JIS0208_to_SJIS methodsFor:'encoding & decoding'!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
decodeString:aString
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    "return a new JIS-Encoded-String containing the characters from aString,
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
     which are interpreted as Shift-JIS encoded singleByte chars.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
     Shift-JIS is a leadyByte code, with a variable-length encoding."
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    |newString char1 char2
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
     sz         "{ Class: SmallInteger }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
     dstIdx     "{ Class: SmallInteger }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
     srcIdx     "{ Class: SmallInteger }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
     b1         "{ Class: SmallInteger }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
     b2         "{ Class: SmallInteger }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
     val        "{ Class: SmallInteger }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
     any16bit romans|
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    sz := aString size.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    sz == 0 ifTrue:[^ aString].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    newString := TwoByteString new:sz.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    any16bit := false.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    dstIdx := 1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    srcIdx := 1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    romans := CharacterEncoderImplementations::JIS0208 romanTable.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
%{
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    if (__isStringLike(aString)
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
     && (__Class(newString) == @global(TwoByteString))) {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
        INT _dstIdx = 0, _srcIdx = 0;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
        int _sz = __intVal(sz);
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
        unsigned char *_cp = __stringVal(aString);
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
        unsigned char _c1, _c2;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
        unsigned short *_jcp = (unsigned short *)__stringVal(newString);
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
        while (_srcIdx < _sz) {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
            int _val;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
            _c1 = _cp[_srcIdx];
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
            _srcIdx++;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
            if ((_srcIdx < _sz)
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
             && (((_c1 >= 129) && (_c1 <= 159))
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
                 || ((_c1 >= 224) && (_c1 <= 239)))) {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
                _c2 = _cp[_srcIdx];
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
                _srcIdx++;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
                if ((_c2 >= 64) && (_c2 <= 252)) {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
                    int _adjust, _rowOffs, _cellOffs;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
                    int _b1, _b2;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
                    _adjust = (_c2 < 159) ? 1 : 0;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
                    _rowOffs = (_c1 < 160) ? 112 : 176;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
                    if (_adjust) {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
                        _cellOffs = 31 + ((_c2 > 127) ? 1 : 0);
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
                    } else {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
                        _cellOffs = 126;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
                    }
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
                    _b1 = ((_c1 - _rowOffs) << 1) - _adjust;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
                    _b2 = (_c2 - _cellOffs);
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
                    _val = (_b1<<8) + _b2;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
                    if (_val <= 0) {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
                        /* decoder error - let smalltalk handle that */
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
                        _srcIdx -= 2;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
                        goto getOutOfHere;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
                    }
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
                    if (_val > 0xFF) any16bit = true;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
                    _jcp[_dstIdx] = _val;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
                } else {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
                    /* mhmh - append untranslated */
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
                    _jcp[_dstIdx] = _c1;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
                    _dstIdx++;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
                    _jcp[_dstIdx] = _c2;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
                }
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
            } else {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
                if ((_c1 >= 0xA1 /* 161 */) && (_c1 <= 0xDF /* 223 */)) {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
                    /* HALFWIDTH KATAKANA
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
                     * map half-width katakana to 8E:xx
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
                     */
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
                    _val = _c1 - 128;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
                    _val = _val + 0x8E00;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
                    any16bit = true;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
                    _jcp[_dstIdx] = _val;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
                } else {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
                    /* roman characters are translated as per romanTable */
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
                    _jcp[_dstIdx] = _c1;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
                    if ((romans != nil) 
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
                     && (__isArray(romans))
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
                     && ((_c1 - 0x20) < __arraySize(romans))) {
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
                        any16bit = true;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
                        _jcp[_dstIdx] = __intVal(__ArrayInstPtr(romans)->a_element[(_c1 - 0x20)]);
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
                    }
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
                }
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
            }
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
            _dstIdx++;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
        }
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    getOutOfHere: ;
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
        dstIdx = __mkSmallInteger(_dstIdx+1);
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
        srcIdx = __mkSmallInteger(_srcIdx+1);
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    }
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
%}.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    [srcIdx <= sz] whileTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
        "/
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
        "/ scan for next character in 129..159 or 224..239
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
        "/
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
        char1 := aString at:srcIdx.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
        srcIdx := srcIdx + 1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
        b1 := char1 codePoint.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
        ((srcIdx <= sz) 
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
        and:[(b1 >= 16r81"129" and:[b1 <= 16r9F"159"])                 "/ SJIS1 81 .. 9F
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
             or:[b1 >= 16rE0"224" and:[b1 <= 16rEF"239"]]]) ifTrue:[   "/       E0 .. EF
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
            char2 := aString at:srcIdx.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
            srcIdx := srcIdx + 1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
            b2 := char2 codePoint.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
            (b2 >= 16r40"64" and:[b2 <= 16rFC"252"]) ifTrue:[          "/ SJIS2 40 .. FC
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
                |adjust rowOffs cellOffs|
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
                adjust := (b2 < 16r9F"159") ifTrue:[1] ifFalse:[0].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
                rowOffs := b1 < 16rA0"160" ifTrue:[112] ifFalse:[176].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
                adjust == 1 ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
                    cellOffs := 31 + (b2 > 127 ifTrue:[1] ifFalse:[0]).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
                ] ifFalse:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
                    cellOffs := 126.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
                ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
                b1 := ((b1 - rowOffs) bitShift:1) - adjust.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
                b2 := (b2 - cellOffs).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
                val := (b1 bitShift:8) + b2.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
                val <= 0 ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
                    DecodingError
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
                            raiseWith:aString
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
                            errorString:'SJIS decoding failed (not SJIS encoded ?)'.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
                    newString at:dstIdx put:char1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
                    dstIdx := dstIdx + 1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
                    newString at:dstIdx put:char2.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
                ] ifFalse:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
                    val > 16rFF ifTrue:[any16bit := true].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
                    newString at:dstIdx put:(Character value:val).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
                ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
            ] ifFalse:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
                "/ mhmh - append untranslated
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
                newString at:dstIdx put:char1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
                dstIdx := dstIdx + 1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
                newString at:dstIdx put:char2.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
            ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
        ] ifFalse:[    
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
            (b1 >= 16rA1 "161" and:[b1 <= 16rDF "223"]) ifTrue:[     "/ HALFWIDTH KATAKANA
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
                "/ map half-width katakan to 8E:xx
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
                val := b1 - 128.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
                val := val + (16r8E"142" bitShift:8).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
                any16bit := true.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
                newString at:dstIdx put:(Character value:val).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
            ] ifFalse:[    
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
                "/ roman characters translated as per romanTable
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
                newString at:dstIdx put:char1
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
                romans isArray ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
                    char1 codePoint < romans size ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
                        any16bit := true.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
                        newString at:dstIdx put:(Character value:(romans at:char1 codePoint-32+1)).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
                    ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
                ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
            ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
        ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
        dstIdx := dstIdx + 1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    any16bit ifFalse:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
        newString := String fromString:newString 
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    (dstIdx-1) ~~ sz ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
        newString := newString copyTo:dstIdx - 1.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    ^ newString
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    "simple:
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
     CharacterEncoderImplementations::JIS0208_to_SJIS decodeString:'hello'  
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
     (CharacterEncoder encoderFor:#sjis) decodeString:'hello'         
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
     CharacterEncoderImplementations::JIS0208_to_SJIS decodeString:('../../doc/online/japanese/TOP.html' asFilename contents asString)  
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
     '../../doc/online/japanese/TOP.html' asFilename contents asString
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
                decodeFrom:#sjis  
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    "
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
encodeString:aJISString
18243
ef19ec73cad1 class: CharacterEncoderImplementations::JIS0208_to_SJIS
Claus Gittinger <cg@exept.de>
parents: 18241
diff changeset
   245
    "return a new string with aJISString's characters as SJIS encoded 8bit string.
18241
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
     The resulting string is only useful to be stored on some external file,
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
     not for being displayed in an ST/X view."
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    |sz "{ Class: SmallInteger }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
     rval "{ Class: SmallInteger }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
     val  "{ Class: SmallInteger }"
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
     romans c out isSJIS|
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    romans := JIS0208 romanTable.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    sz := aJISString size.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    sz == 0 ifTrue:[^ ''].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    out := WriteStream on:(String new:(sz * 2)).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    1 to:sz do:[:srcIndex |
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
        val := (c := aJISString at:srcIndex) codePoint.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
        (val <= 128) ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
            "/ a control or ascii character    
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
            out nextPut:c.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
        ] ifFalse:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
            (val == 16rFFFF "invalid-char") ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
                out nextPut:Character space.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
            ] ifFalse:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
                (val > 150 and:[val < 224]) ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
                    "/ ascii subset
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
                    out nextPut:c.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
                ] ifFalse:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
                    "/ should not happen ...
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
                    val <= 255 ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
                        out nextPut:c.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
                    ] ifFalse:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
                        isSJIS := true.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
                        "/ check for HALFWIDTH KATAKANA
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
                        "/ 8E:xx
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
                        "/ NO: halfwidth katakana no longer generated
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
                        "/     remains there as full-width katakana
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
"/                        (val bitAnd:16rFF00) == 16r8E00 ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
"/                            |b|
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
"/
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
"/                            b := (val bitAnd:16rFF) + 128.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
"/                            (b >= 16rA1 "161" and:[b <= 16rDF "223"]) ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
"/                                out nextPut:(Character value:b).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
"/                                isSJIS := false.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
"/                            ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
"/                        ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
                        isSJIS ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
                            "/ check for a roman character
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
                            (val between:"romanTable min" 16r2121 and:"romanTable max" 16r2573) ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
                                rval := romans indexOf:val.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
                                rval ~~ 0 ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
                                    rval := rval - 1 + 32.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
                                    rval <= 16r7F ifTrue:[ "/ do not translate halfwidth katakana
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
                                        out nextPut:(Character value:rval).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
                                        isSJIS := false.
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
                                    ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
                                ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
                            ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
                        ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
                        isSJIS ifTrue:[
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
                            |b1 b2 rowOffset cellOffset|
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
                            b1 := (val bitShift:-8).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
                            b2 := (val bitAnd:16rFF).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
                            rowOffset := (b1 < 95) ifTrue:[112] ifFalse:[176].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
                            cellOffset := b1 odd ifTrue:[(b2 > 95) ifTrue:[32] ifFalse:[31]]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
                                                 ifFalse:[126].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
                            out nextPut:(Character value:(((b1 + 1) bitShift:-1) + rowOffset)).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
                            out nextPut:(Character value:b2 + cellOffset).
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
                        ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
                    ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
                ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
            ]
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
        ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    ].
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    ^ out contents
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
! !
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
!JIS0208_to_SJIS methodsFor:'private'!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
newString:size
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
    ^ JISEncodedString new:size
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
! !
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
!JIS0208_to_SJIS methodsFor:'queries'!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
nameOfEncoding
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
    ^ #'sjis'
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
! !
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
!JIS0208_to_SJIS class methodsFor:'documentation'!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
version
18243
ef19ec73cad1 class: CharacterEncoderImplementations::JIS0208_to_SJIS
Claus Gittinger <cg@exept.de>
parents: 18241
diff changeset
   344
    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__JIS0208_to_SJIS.st,v 1.2 2015-04-20 11:05:35 cg Exp $'
18241
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
!
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
version_CVS
18243
ef19ec73cad1 class: CharacterEncoderImplementations::JIS0208_to_SJIS
Claus Gittinger <cg@exept.de>
parents: 18241
diff changeset
   348
    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__JIS0208_to_SJIS.st,v 1.2 2015-04-20 11:05:35 cg Exp $'
18241
c594840ddf15 renamed to make filename compliant to class name
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
! !
18243
ef19ec73cad1 class: CharacterEncoderImplementations::JIS0208_to_SJIS
Claus Gittinger <cg@exept.de>
parents: 18241
diff changeset
   350