Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5cbc57ad30deea62210e063286347f6b3459105d
Ticket: 219283ffffffffffffffffffffffffffffffffff
iso2022-jp encoding is broken
User & Date: nobody on 2000-10-26 05:09:54
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 1933 Bug
    Version: 8.1b3
    SubmitDate: '1999-04-26'
    LastModified: '1999-04-26'
    Severity: CRIT
    Status: UnAssn
    Submitter: stanton
    ChangedBy: stanton
    OS: All
    OSVersion: NA
    Machine: NA
    FixedDate: '2000-10-25'
    FixedInVersion: NA
    ClosedDate: '2000-10-25'
    
    
    It does not work well unfortunately.  I used this script with the cvs 
    version of core8.1 on Digital-Unix 4.0B and Linux 2.0.36.  I'll 
    describe the details below. 
    
    =====
    #!/usr/new/bin/tclsh8.1
    # eucjis
    # k.furukawa, apr.24.1999. 
    # based on message from scott stanton
    
    set usage "eucjis (-eucjjis|-jiseuc) (-read|-gets) {input-file} {output-file}"
    foreach {eucjis read input output} $argv {}
    if {$output == ""} { puts stderr $usage ; exit 1 }
    set infile [open $input r]
    set outfile [open $output w]
    switch -- $eucjis {
        -eucjis {
            fconfigure $infile -encoding euc-jp
            fconfigure $outfile -encoding iso2022-jp
        } -jiseuc {
            fconfigure $infile -encoding iso2022-jp
            fconfigure $outfile -encoding euc-jp
        } default { puts stderr $usage ; exit 1 }
    }
    switch -- $read {
        -read {
            puts -nonewline $outfile [read $infile]
        } -gets {
            while {[gets $infile line] != -1} {
                puts $outfile $line
            }
        } default { puts stderr $usage ; exit 1 }
    }
    close $infile ; close $outfile
    =====
    
    (1) Old character set (not serious)
    
    Texts generated by tcl's iso2022-jp are lead by "<ESC> $ @", which 
    is an old sequence.  Rfc1468 and rfc1554 says 
          reg#  character set      ESC sequence                designated to
          ------------------------------------------------------------------
          6     ASCII              ESC 2/8 4/2      ESC ( B    G0
          42    JIS X 0208-1978    ESC 2/4 4/0      ESC $ @    G0
          87    JIS X 0208-1983    ESC 2/4 4/2      ESC $ B    G0
          14    JIS X 0201-Roman   ESC 2/8 4/10     ESC ( J    G0
    Character sets of 0208-1978 and 0208-1983 are slightly different.  
    If we don't want to specify the old character set explicitly, we 
    should use the new character set, 0208-1983, which is lead by 
    "<ESC> $ B". 
    
    (2) Unnecessary sequences (not serious)
    
    If I puts each line using "-gets" option above, each line is lead 
    by "<ESC> ( B" and followed by "<ESC> ( B", even if the line is all 
    composed of ASCII characters.  They are simply not necessary.  Only 
    Japanese (0208-1983) texts should be surrounded by "<ESC> $ B" and 
    "<ESC> ( B". 
    
    (3) Not conveted right from iso2022-jp to euc-jp (serious)
    
    I'll attach an example file jis1.txt.  The file is not converted 
    right with a command 
    "tclsh8.1 eucjis.tcl -jiseuc -gets jis1.txt euc1.txt". 
    The last character should be hexadecimal <A5><F3>, while tcl outputs 
    ASCII "%s".  I could find many examples.  Another example is jis2.txt, 
    which has 5 characters not converted right. 
    
    (4) Infinite loop in conversion from euc-jp to iso2022-jp (serious)
    
    If I convert line by line with "-gets" option above, the script 
    converts euc-jp texts into iso2022-jp, although it contains many 
    unnecessary escape sequences as described in (2).  
    
    However, if I use "-read", it sometimes goes into an infinite loop in 
    "puts", and outputs "<ESC> ( B" repeatedly.  It does not occur with 
    short texts.  I'll attach one of the example input file "euc.txt". 
    
    Sorry, I don't have time now to debug the tcl's encoding system.  But 
    if you have more questions, please ask me. 
    
    jis1.txt and jis2.txt are encoded in iso2022-jp, euc.txt in euc-jp. 
    
    Regards, Kazuro. 
    -----
    Kazuro FURUKAWA <[email protected]>  (or <[email protected]>)
     Linac,  High Energy Accelerator Research Organization (KEK), Japan
    
    
    This looks like there may be a problem with the 2022 encoding.  We need to verify the sub-tables and possibly change the order of the prefixes in the file to give preference to the newer sub-encodings.
    
    
    
  4. foundin changed to: "obsolete: 8.1b3"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "57. zlib"
  10. title changed to: "iso2022-jp encoding is broken"
  11. type changed to: "Bug"