String (gb)
该类提供UTF-8字符串操作方法。
该类是静态类。
静态方法
注意:标准Gambas字符串函数仅仅处理ASCII码字符串。
要使用非UTF8字符串,必须首先使用
Conv$进行转换。
示例
DIM hFile AS Stream
DIM sOneNonUTF8Line AS String
DIM sUTF8Line as String
' Print a WINDOWS-1253 text file to standard output
hFile = OPEN "/home/ilias/sometextingreekWINDOWS-1253.txt" FOR INPUT
WHILE NOT Eof(hFile)
LINE INPUT #hFile, sOneNonUTF8Line
sUTF8Line = Conv$(sOneNonUTF8Line, "WINDOWS-1253", "UTF-8")
PRINT sUTF8Line
'alternatively
'LINE INPUT #hFile, sOneNonUTF8Line
'PRINT Conv$(sOneNonUTF8Line, "WINDOWS-1253", "UTF-8")
WEND
FINALLY ' Always executed, even if an error is raised
CLOSE #hFile
CATCH ' Executed only if there is an error
PRINT "Cannot print or read or convert lines from file "; "/home/ilias/sometextingreekWINDOWS-1253.txt"