2001.5.7
TNTmips V6.5
SMLストリング関数のエラー
mid$関数などでファイルから漢字を読む際、要注意です。
漢字によってはカラムずれを起こします。
(A)問題のない漢字
テキストファイルに以下の漢字あり。
12345輪座6789
これを以下のSMLで読むと、以下の結果になる。ちゃんと漢字1文字2バイトで読んでいる。
SML:
-------------------
clear()
infile=fopen("d:/data/text1.txt","r")
line$=fgetline$(infile)
num1$=left$(line$,5) <--"12345"を読む。
some_kanji$=mid$(line$,6,4) <--"輪座"を読む(漢字1文字=英数2文字分)。
num2$=mid$(line$,10,4) <--"6789"を読む。
printf("num1 is %s\n",num1$)
printf("some_kanji is %s\n",some_kanji$)
printf("num2 is %s\n",num2$)
fclose(infile)
beep()
-------------------
結果:

(B)問題のある漢字
(例1)12345村上6789
村上の"上"の字を、1バイトとして判断するようです。そのため6が前にずれこんで読まれます。
250m標高5739がこの図郭名です。
(例2)12345上山6789
"山"の字も1バイトとして判断されるようです。そのため6と7の2バイトが前にずれこんできています。
本症状はマイクロイメージ社に改善を求め、報告済みです。2バイト言語に共通した問題でしょう。
ちゃんと表示もしてほしい。
In reference to your email and fax of 3 May. Chances are, as you
mention, all of the string functions in SML do not handle Kanji. There
are probably other languages as well, such as the two (2) bytes
languages, which do not work correctly. Having the script and the text
files really helps. I have written this up as tdp2796e and when an
update is available I will let you know.