2013/02/28

List all SHIFT-JIS code (UTF8 version)

List almost all SHIFT-JIS code which was supported in X68000.
It produced SHIFT-JIS code in arithmetic, and it convert to UTF8 when displaying.
Please run under SHIFT-JIS forced mode is OFF.
/* List all SHIFT-JIS code by UTF8
// X-BASIC for iOS can not text screen scroll, so it is displayed page by page.
    font("Migu 1M")
    int fzenhan:// YES=
    width(64,,fzenhan)
    print "fzenhan=";fzenhan
    cls()
    
    if isLocalizeJapan() then {
        setFunctionKey(0,"次へ",&h0d)
        setFunctionKey(1,"中断",&h1b)
        print "半角文字"
    } else {
        setFunctionKey(0,"Next",&h0d)
        setFunctionKey(1,"Break",&h1b)
        print "Half-Width Character"
    }
    print_code0(fzenhan)
    //
    displayFunctionKey(YES,0,1)
    //
    while YES
        if print_code(&h8100,&h9fff) then break
        if print_code(&he000,&hefff) then break
        print_head()
        break
    endwhile
    // The previous function key display will not erase automatically when changing the number.
    // The user must erase(View overlaps with otherwise).
    displayFunctionKey(NO,0,1)
    if isLocalizeJapan() then {
        setFunctionKey(0,"終了",&h0d)
    } else {
        setFunctionKey(0,"End",&h0d)
    }
    displayFunctionKey(YES,0,0)
    int ky
    repeat
        ky=inkey()
    until ky<>0
end

//--------------------------------

func print_head()
    if fzenhan then {
        print "-code-:-+0-+1-+2-+3-+4-+5-+6-+7-+8-+9-+A-+B-+C-+D-+E-+F-"
    } else {
        print "-code-:-0-1-2-3-4-5-6-7-8-9-A-B-C-D-E-F-"
    }
endfunc

func print_skip()
    print "      :                                                "
endfunc

func str hex4$(h;int)
    return (right$("0000"+hex$(h),4))
endfunc

func str hex2$(h;int)
    return (right$("00"+hex$(h),2))
endfunc

func printChr(h;int,l;int)
    print chr$((h shl 16)or l);
endfunc

func int print_code(st;int,ed;int)
/* Double-Width character display 
int i,li,hi
int j
    for i=st to ed
        hi=i / 256
        li=i mod 256
        if li=0 then {
            print_head()
            int ky
            int ts=time()
            int dt=0,t
            repeat
                ky=inkey()
                t=time()
                if t-ts>dt then { :/* change second
                    dt=dt+1
                    locate(40,0):print dt
                    beep2(0)
                }
            until ky<>0
            if ky=&h1b then return (YES)
            cls()
            if isLocalizeJapan() then {
                print "全角文字"
            } else {
                print "Double-Width character"
            }
            print_head()
        }
        if li<&h40 then continue:/* The chatacter which low 8bit code<$40 is none
        
        /* print adrs 
        print " ";hex4$(i);" :";
        for j=0 to 16-1
            print " ";
            int c=(i+j) and &hff
            if c<&h40 or c=&h7f or c>=&hfd then { /* undefined character
                if fzenhan then {
                    print "**";
                } else {
                    print "*";
                }
            } else {
                c=sjisToUtf8(i+j)
                print chr$(c); :/* This was treated on the assumption that it does not cause a carry on the way
            }
        next
        print
        i=i+16-1:/* +1 in below 'next'
    next
    return (NO)
endfunc

func print_code0(fzenhan;int)
/* half width character display 
int li
int j,c
    print_head()
    for li=&h20 to &he0-1
        /* skip area 
        if li=&h80 then print_skip()
        if li>=&h80 and li<=&h9f then continue
        
        /* print adrs 
        print "  ";hex2$(li);"  :";
        /* print character
        for j=0 to 16-1
            print " ";
            c=li+j
            if c=&h7f or c=&ha0 then c='*' else c=sjisToUtf8(c)
            print chr$(c);
            if fzenhan then print " ";:/* if Double-width equal half-width*2 then print space
        next
        print
        li=li+16-1:/* +1 in below 'next'
    next
endfunc

Zip file is here : XBetc.zip

No comments:

Post a Comment