#3 utf7 encoded strings by python does not accepted

closed-fixed
nobody
None
5
2005-05-30
2004-08-10
Anonymous
No

Hello,

I have a problem with the fontforge.

The problem is related with a UTF7 encoded fontname.

I use some script to generate UTF7 encoded Korean
strings with the following simple script with the Python2.3

$ python -c "print
'$FONTNAME'.decode('EUCKR').encode('UTF7')

for example, it emit "+x0A +vQQ-"

but fontforge does not accept this valid utf7 encoded names
(fontforge accept only "+x0AA +vQQA" encoded by itself)

Then, I contact with a python developer about this
problem, and he make some
patch for me and It works!!

I attach utf7 related patch. It accept above python
encoded strings and old
style (used by fontforge) strings too.

Please apply this patch (by Hye-Shik Chang
<perky@FreeBSD.org>)

Regards,

Won-kyu Park <wkpark@kldp.org>

Discussion

  • Won Kyu Park
    Won Kyu Park
    2004-08-10

    Logged In: YES
    user_id=76597

    oops

    this is a patch
    -------------
    --- sfd.c.orig 2004-08-10 23:48:44.348876576 +0900
    +++ sfd.c 2004-08-10 23:50:13.011397824 +0900
    @@ -160,7 +160,7 @@
    static unichar_t *SFDReadUTF7Str(FILE *sfd) {
    unichar_t buffer[1024], *pt, *end =
    buffer+sizeof(buffer)/sizeof(unichar_t)-1;
    #endif
    - int ch1, ch2, ch3, ch4, done;
    + int ch1, ch2, ch3, ch4, done, c;
    int prev_cnt=0, prev=0, in=0;

    ch1 = getc(sfd);
    @@ -193,9 +193,23 @@
    done = true;
    } else {
    ch1 = inbase64[ch1];
    - ch2 = inbase64[getc(sfd)];
    - ch3 = inbase64[getc(sfd)];
    - ch4 = inbase64[getc(sfd)];
    + ch2 = inbase64[c = getc(sfd)];
    + if ( ch2==-1 ) {
    + ungetc(c, sfd);
    + ch2 = ch3 = ch4 = 0;
    + } else {
    + ch3 = inbase64[c = getc(sfd)];
    + if ( ch3==-1 ) {
    + ungetc(c, sfd);
    + ch3 = ch4 = 0;
    + } else {
    + ch4 = inbase64[c = getc(sfd)];
    + if ( ch4==-1 ) {
    + ungetc(c, sfd);
    + ch4 = 0;
    + }
    + }
    + }
    ch1 = (ch1<<18) | (ch2<<12) | (ch3<<6) | ch4;
    if ( prev_cnt==0 ) {
    prev = ch1&0xff;

     
    • status: open --> closed-fixed
     
  • Logged In: YES
    user_id=201273

    Thanks, Applied.