ひらがな
↑↓
半角カタカナ → 全角カタカナ
←
半角数字 全角数字
半角英字 全角英字
半角記号 全角記号
を行うサブルーチンをつくってみました。
DECLARE EXTERNAL FUNCTION StrConv.ASC$ ,StrConv.JIS$ !半角、全角
DECLARE EXTERNAL FUNCTION StrConv.ToHiragana$ ,StrConv.ToKatakana$ !ひらがな、カタカナ
LET t$="BASICプログラミングーぅ~!"
PRINT ASC$(t$) !半角へ
PRINT JIS$(ASC$(t$)) !全角へ
PRINT ToKatakana$("abcXYZあいうカキク890 *?")
PRINT ToHiragana$("abcXYZあいうカキク890 *?")
END
MODULE StrConv !文字の変換
!「半角 → 全角」対応表 ※JISコード(JIS X 0201)順
DATA " "," " !32
DATA "!","!" !33
DATA """","”" !34
DATA "#","#" !35
DATA "$","$" !36
DATA "%","%" !37
DATA "&","&" !38
DATA "'","’" !39
DATA "(","(" !40
DATA ")",")" !41
DATA "*","*" !42
DATA "+","+" !43
DATA ",","," !44
DATA "-","-" !45
DATA ".","." !46
DATA "/","/" !47
DATA "0","0" !48
DATA "1","1" !49
DATA "2","2" !50
DATA "3","3" !51
DATA "4","4" !52
DATA "5","5" !53
DATA "6","6" !54
DATA "7","7" !55
DATA "8","8" !56
DATA "9","9" !57
DATA ":",":" !58
DATA ";",";" !59
DATA "<","<" !60
DATA "=","=" !61
DATA ">",">" !62
DATA "?","?" !63
DATA "@","@" !64
DATA "A","A" !65
DATA "B","B" !66
DATA "C","C" !67
DATA "D","D" !68
DATA "E","E" !69
DATA "F","F" !70
DATA "G","G" !71
DATA "H","H" !72
DATA "I","I" !73
DATA "J","J" !74
DATA "K","K" !75
DATA "L","L" !76
DATA "M","M" !77
DATA "N","N" !78
DATA "O","O" !79
DATA "P","P" !80
DATA "Q","Q" !81
DATA "R","R" !82
DATA "S","S" !83
DATA "T","T" !84
DATA "U","U" !85
DATA "V","V" !86
DATA "W","W" !87
DATA "X","X" !88
DATA "Y","Y" !89
DATA "Z","Z" !90
DATA "[","[" !91
DATA "\","¥" !92
DATA "]","]" !93
DATA "^","^" !94
DATA "_","_" !95
DATA "`","‘" !96
DATA "a","a" !97
DATA "b","b" !98
DATA "c","c" !99
DATA "d","d" !100
DATA "e","e" !101
DATA "f","f" !102
DATA "g","g" !103
DATA "h","h" !104
DATA "i","i" !105
DATA "j","j" !106
DATA "k","k" !107
DATA "l","l" !108
DATA "m","m" !109
DATA "n","n" !110
DATA "o","o" !111
DATA "p","p" !112
DATA "q","q" !113
DATA "r","r" !114
DATA "s","s" !115
DATA "t","t" !116
DATA "u","u" !117
DATA "v","v" !118
DATA "w","w" !119
DATA "x","x" !120
DATA "y","y" !121
DATA "z","z" !122
DATA "{","{" !123
DATA "|","|" !124
DATA "}","}" !125
DATA "~","~" !126
DATA "。","。" !161
DATA "「","「" !162
DATA "」","」" !163
DATA "、","、" !164
DATA "・","・" !165
DATA "ヲ","ヲ" !166
DATA "ァ","ァ" !167
DATA "ィ","ィ" !168
DATA "ゥ","ゥ" !169
DATA "ェ","ェ" !170
DATA "ォ","ォ" !171
DATA "ャ","ャ" !172
DATA "ュ","ュ" !173
DATA "ョ","ョ" !174
DATA "ッ","ッ" !175
DATA "ー","ー" !176
DATA "ア","ア" !177
DATA "イ","イ" !178
DATA "ウ","ウ" !179
DATA "エ","エ" !180
DATA "オ","オ" !181
DATA "カ","カ" !182
DATA "キ","キ" !183
DATA "ク","ク" !184
DATA "ケ","ケ" !185
DATA "コ","コ" !186
DATA "サ","サ" !187
DATA "シ","シ" !188
DATA "ス","ス" !189
DATA "セ","セ" !190
DATA "ソ","ソ" !191
DATA "タ","タ" !192
DATA "チ","チ" !193
DATA "ツ","ツ" !194
DATA "テ","テ" !195
DATA "ト","ト" !196
DATA "ナ","ナ" !197
DATA "ニ","ニ" !198
DATA "ヌ","ヌ" !199
DATA "ネ","ネ" !200
DATA "ノ","ノ" !201
DATA "ハ","ハ" !202
DATA "ヒ","ヒ" !203
DATA "フ","フ" !204
DATA "ヘ","ヘ" !205
DATA "ホ","ホ" !206
DATA "マ","マ" !207
DATA "ミ","ミ" !208
DATA "ム","ム" !209
DATA "メ","メ" !210
DATA "モ","モ" !211
DATA "ヤ","ヤ" !212
DATA "ユ","ユ" !213
DATA "ヨ","ヨ" !214
DATA "ラ","ラ" !215
DATA "リ","リ" !216
DATA "ル","ル" !217
DATA "レ","レ" !218
DATA "ロ","ロ" !219
DATA "ワ","ワ" !220
DATA "ン","ン" !221
DATA "゙","゛" !222
DATA "゚","゜" !223
!「全角カタカナ → 半角カタカナ」の対応表
DATA "ァ","ァ", "ア","ア", "ィ","ィ", "イ","イ", "ゥ","ゥ", "ウ","ウ", "ェ","ェ", "エ","エ", "ォ","ォ", "オ","オ"
DATA "カ","カ", "ガ","ガ", "キ","キ", "ギ","ギ", "ク","ク", "グ","グ", "ケ","ケ", "ゲ","ゲ", "コ","コ", "ゴ","ゴ"
DATA "サ","サ", "ザ","ザ", "シ","シ", "ジ","ジ", "ス","ス", "ズ","ズ", "セ","セ", "ゼ","ゼ", "ソ","ソ", "ゾ","ゾ"
DATA "タ","タ", "ダ","ダ", "チ","チ", "ヂ","ヂ", "ッ","ッ", "ツ","ツ", "ヅ","ヅ", "テ","テ", "デ","デ", "ト","ト", "ド","ド"
DATA "ナ","ナ", "ニ","ニ", "ヌ","ヌ", "ネ","ネ", "ノ","ノ"
DATA "ハ","ハ", "バ","バ", "パ","パ", "ヒ","ヒ", "ビ","ビ", "ピ","ピ", "フ","フ", "ブ","ブ", "プ","プ", "ヘ","ヘ", "ベ","ベ", "ペ","ペ", "ホ","ホ", "ボ","ボ", "ポ","ポ"
DATA "マ","マ", "ミ","ミ", "ム","ム", "メ","メ", "モ","モ"
DATA "ャ","ャ", "ヤ","ヤ", "ュ","ュ", "ユ","ユ", "ョ","ョ", "ヨ","ヨ"
DATA "ラ","ラ", "リ","リ", "ル","ル", "レ","レ", "ロ","ロ"
DATA "ヮ","ワ", "ワ","ワ", "ヰ","イ", "ヱ","エ", "ヲ","ヲ", "ン","ン", "ヴ","ヴ", "ヵ","カ", "ヶ","ケ"
SHARE STRING JisTBL$(0 TO 255), KataTBL$(9505 TO 9590)
DO
READ IF MISSING THEN EXIT DO : a$,aa$ !インデックス、変換値
IF ORD(a$)<256 THEN
LET JisTBL$(ORD(a$))=aa$ !ハッシュ表をつくる
ELSE
LET KataTBL$(ORD(a$))=aa$
END IF
LOOP
!-------------------- ここまでが初期処理
つづく