자바 1.1


[ Follow Ups ] [ Post Followup ] [ 자바 묻고 답하기 ]

Posted by 윤경구 on February 25, 1997 at 16:00:25:

In Reply to: 자바 한글지원 여부 posted by 박진규 on February 25, 1997 at 10:15:07:

자바 1.1 버전이 한글을 거의 제대로 지원합니다.
다음은 관련된 글들입니다.
글 1 (from news:han.comp.hangul)
-------------------------------

native2ascii의 document에는 빠져 있지만, 
`native2ascii -encoding KSC5601'이라고 수행하면, Unicode-encoded ascii
file로 conversion해 주더군요.
또한, 다른 문서에서는 jdk1.1이 KSC5601 code를 지원한다고 되어 있습니다.

참고로, 한글로 작성한 java source code (즉, 한글 변수, 한글 string등을 사용한)
를 이와같이 Unicode-encoded ascii file로 conversion해서 compile할 수 있습니다.

Hwin95에서는 (Solaris에서는 LANG 변수가 ko로 setting되어 있는 경우)
java compiler가 source code를 KSC5601문서로 인식해서 코드 변환 후 
compile해주므로, native2ascii는 그다지 필요성이 높지는 않습니다.

TextField, 입출력 class등 여러 class에서도 KSC5601 code의 입력,
Unicode와의 code 변환등이 수행됩니다.

현재, 제가 test해 본 바로는 Unicode로부터 KSC5601 code로 변환은
문제가 없는 것으로 보이나, KSC5601 code로부터 Unicode로의 변환은
약간의 bug가 있습니다. 이 변환을 담당하는 class가
sun.io.ByteToCharKSC5601인데, 이 class의 bug만 고치면, 한글 code 변환과
관련된 문제는 거의 모두 해결되리라 생각됩니다.

이 class에서 현재 제가 발견한 bug는 변환할 KSC5601 문서에서 
중간 중간에 문자를 빼먹고 code변환을 한다는 것입니다.
하지만, 여러번에 걸쳐서 code 변환을 하는 것이 아니라,
한꺼번에 code 변환을 하는 경우에는 이러한 bug가 생기지 않습니다.

예를 들어,
native2ascii는 한꺼번에 code변환을 하기때문인지 bug가 발견되지 않았습니다.
기타, 한글 문서를 읽어들일 때에도 BufferedReader등을 앞에 붙여서
한번에 code변환이 되도록 해주면 잘 동작할 것입니다.

예: Reader in = new BufferedReader(new FileReader("doc.ks"))

Sun에서는 bug report를 받아서 jdk1.1의 bug를 고친 jdk1.11을 
조만간 발표할 것이라고 하니, 여기에 기대해 봅니다.

--
김 덕태 (dtkim@camars.kaist.ac.kr)
KAIST CS Dept. CA Lab

글 2 (from news:han.comp.hangul)
-------------------------------

> 
> Yoon Kyung Koo wrote:
> >
> > I tested JDK 1.1 final release on Hangul Windows NT 4.0 (Workstaion
> > version).
> > First, TextArea and TextField works on input and display but have some
> > problems...
> > When these TextComponents get hangul input including space (or
> > punctuation marks) they added '?' after space (or punctuation marks)
> > occasionally.
> 
> I don't know why those components generate such garbage key events.
> However, if you remove those bad events as follows,
> the problem can be solved.
> 
> ---------------------------
> import java.awt.*;
> import java.awt.event.*;
> 
> class TextAreaTest extends Frame
> {   TextArea ta = new TextArea();
>     {   add(ta, "Center");
>     }
>     public static void main(String[] args)
>     {   TextAreaTest f = new TextAreaTest();
>         f.ta.addKeyListener(new KeyAdapter()
>         {   public void keyTyped(KeyEvent ev)
>             {   if (ev.getKeyCode() == 0
>                     && ev.getKeyChar() == '?')
>                     ev.consume();
>             }
>         });
>         f.setSize(300, 300);
>         f.setVisible(true);
>     }
> }
> ---------------
> 
> > And I couldn't get args's correct value for Hangul in main methods.
> > This can be my fault. I am confused about the string value of args[]
> > in main method. Are the string value of args[] converted unicode value
> > of localized input, aren't they?
> > Could anybody tell me how I can handle hangul characters as args of
> > main method?
> 
> In Solaris, if LANG variable is set to "ko"
> java interpreter treat argument as KSC5601 code.
> But in Hangul Windows 95, it treat argument as ISO8859-1
> 
> This problem can be solved as follows.
> String class provide constructors and methods for code conversion.
> You can get original bytes of the argument by converting argument string
> to ISO8859-1 bytes.
> And then, you can convert the original bytes to Unicode using
> KSC5601-to-Unicode conversion
> 
> ------------------------
> class ArgTest
> {   public static void main(String[] args)
>         throws java.io.UnsupportedEncodingException
>     {   System.out.println(args[0]);
> 
>         byte[] rawBytes = args[0].getBytes("8859_1");
>         String correctedString = new String(rawBytes, "KSC5601");
>         System.out.println(correctedString);
>     }
> }
> ------------------------
> 
> --
> Deogtae Kim (김덕태)
> CA Lab. CS Dept. KAIST
> E-Mail : dtkim@camars.kaist.ac.kr
> Phone  : +82-42-869-3569
> Fax    : +82-42-869-3510
Yoon Kyung Koo wrote:
> 
> I tested JDK 1.1 final release on Hangul Windows NT 4.0 (Workstaion
> version).
> First, TextArea and TextField works on input and display but have some
> problems...
> When these TextComponents get hangul input including space (or
> punctuation marks) they added '?' after space (or punctuation marks)
> occasionally.

I don't know why those components generate such garbage key events.
However, if you remove those bad events as follows, 
the problem can be solved. 

---------------------------
import java.awt.*;
import java.awt.event.*;

class TextAreaTest extends Frame
{   TextArea ta = new TextArea();
    {   add(ta, "Center");
    }
    public static void main(String[] args)
    {   TextAreaTest f = new TextAreaTest();
        f.ta.addKeyListener(new KeyAdapter()
        {   public void keyTyped(KeyEvent ev)
            {   if (ev.getKeyCode() == 0
                    && ev.getKeyChar() == '?')
                    ev.consume();
            }
        });
        f.setSize(300, 300);
        f.setVisible(true);
    }
}
---------------

> And I couldn't get args's correct value for Hangul in main methods.
> This can be my fault. I am confused about the string value of args[]
> in main method. Are the string value of args[] converted unicode value
> of localized input, aren't they?
> Could anybody tell me how I can handle hangul characters as args of
> main method?

In Solaris, if LANG variable is set to "ko"
java interpreter treat argument as KSC5601 code.
But in Hangul Windows 95, it treat argument as ISO8859-1

This problem can be solved as follows.
String class provide constructors and methods for code conversion.
You can get original bytes of the argument by converting argument string
to ISO8859-1 bytes.
And then, you can convert the original bytes to Unicode using
KSC5601-to-Unicode conversion


------------------------
class ArgTest
{   public static void main(String[] args)
        throws java.io.UnsupportedEncodingException
    {   System.out.println(args[0]); 

        byte[] rawBytes = args[0].getBytes("8859_1");
        String correctedString = new String(rawBytes, "KSC5601");
        System.out.println(correctedString);
    }
}
------------------------

-- 
Deogtae Kim (김덕태)
CA Lab. CS Dept. KAIST
E-Mail : dtkim@camars.kaist.ac.kr
Phone  : +82-42-869-3569
Fax    : +82-42-869-3510



Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ 자바 묻고 답하기 ]