まずは IDE など勝手が違うので、多少の忍耐が必要です。
日本語のファイルを扱うのでまずはまってしまったので、まずはファイルの読み書きから書いていきたいと思います。
UTF-8 ファイルを読む方法です。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
integer fp, err | |
blob buf | |
string pathname="text.txt" | |
fp = fileOpen(pathname, StreamMode!, Read!, Shared!) | |
if fp<>-1 then | |
err = fileRead(fp, buf) | |
ie_1.Text=string( buf, encodingUTF8!) | |
fileClose(fp) | |
end if |
UTF-8 ファイルはこれで読み込めます。
書き込みは以下の通りです。
FileOpen で文字コード EncodingUTF8! を指定します。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string filename, pathname | |
integer result | |
string str | |
integer fp, err | |
result = getFileSaveName("Save file as", pathname, filename, "TXT", "Text Files (*.TXT),*.TXT,") | |
if result=1 then | |
fp = fileOpen(pathname, LineMode!, Write!, LockWrite!, Replace!, EncodingUTF8!) | |
if fp<>-1 then | |
str=ie_1.Text | |
err = fileWrite(fp, str) | |
fileClose(fp) | |
end if | |
end if | |