utf-8 - Powerbuilder:在没有 bom 的情况下将 UTF-8 转换为 UTF-8
问题描述
晚安,我需要在powerbuilder中将文本文件从UTF-8转换为没有bom的UTF-8我可以识别并应该从文本中删除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
解决方案
您将数据类型转换为text
编码为blob
UTF-8 并写下文件:
i=FileWriteEx(f, blob(text,EncodingUTF8!) )
推荐阅读
- php - 如何在事件监听器中获取经过身份验证的用户 - Laravel
- sql-server - Azure SQL 数据库上的奇怪池行为
- reactjs - 在操作符中使用 this.state 作为条件会导致 React 出现问题吗?
- docker - 我可以将 Docker 映像挂载为 Docker 中的卷吗?
- php - 使用 PHP 上传图片
- python - 混淆矩阵错误'DataFrame'“对象不可调用”
- javascript - 使用另一个数组的对象属性对数组进行排序
- go - 当 net.Addr 可能是 net.UDPAddr 或 net.TCPAddr 时如何从 net.Addr 获取 IP 和端口
- apache-spark - 在 Zeppelin 上运行 Spark 作业
- wordpress - HTML5 视频结束时的事件