我需要从Access记录集创建一个ANSI文本文件,输出到JSON和YAML.我可以写文件,但输出是原始字符,我需要逃避它们.例如,变音符号O(ö)应为"\ u00f6".
我认为将文件编码为UTF-8会起作用,但事实并非如此.但是,再次查看文件编码,如果你写"没有BOM的UTF-8"那么一切正常.
有谁知道怎么做
a)在没有BOM的情况下将文本写为UTF-8,或b)用ANSI写入但是转义非ASCII字符?
Public Sub testoutput()
Set db = CurrentDb()
str_filename = "anothertest.json"
MyFile = CurrentProject.Path & "\" & str_filename
str_temp = "Hello world here is an ö"
fnum = FreeFile
Open MyFile For Output As fnum
Print #fnum, str_temp
Close #fnum
End Sub
Run Code Online (Sandbox Code Playgroud)