【发布时间】:2020-07-29 04:02:07
【问题描述】:
晚安,我需要将文本文件从 UTF-8 转换为 UTF-8,而无需在 powerbuilder 中使用 bom 我可以识别并应该从文本中删除 bom,但是当我重新录制它时会继续使用 bom,请帮助
integer li_fnum
long ll_bytes
li_fnum = FileOpen(ls_archivo, StreamMode!)
ll_bytes = FileReadEx(li_fnum, lblb_file_contents)
if len(lblb_file_contents) >= 3 then
GetByte(lblb_file_contents, 1, lbt_1)
GetByte(lblb_file_contents, 2, lbt_2)
GetByte(lblb_file_contents, 3, lbt_3)
if lbt_1 = 239 and lbt_2 = 187 and lbt_3 = 191 then // BOM for UTF8 = EF BB BF
// BOM is found - remove it from the blob
lblb_file_contents = BlobMid(lblb_file_contents, 4, len(lblb_file_contents) - 3)
// Check the truncated contents once again
if len(lblb_file_contents) = 0 then
MessageBox("Error", "There's no data in the file!", StopSign!)
return
end if
end if
end if
【问题讨论】:
-
您可以删除长度参数,没有它,它将返回偏移量为 4 的 blob,例如
BlobMid(lbl_file_contents, 4)顺便说一句,这可能会有所帮助> stackoverflow.com/questions/22336948/… -
经过多次尝试,还是去掉了编码,还是非常感谢
标签: utf-8 powerbuilder