How to create a file of ANSI type

I want to create a file of ANSI type so I use below code, unfortunately the created file has a UTF-8 type.
Can you let me know what the wrong is?

TextArea2 just has normal English words.

  Dim FileName As String
  Dim FinalString As String
  FileName = "C:\\TEMP\\500" + ".sql"
  
  Dim f As FolderItem = New FolderItem(fileName,FolderItem.PathTypeAbsolute)
  Dim t As TextOutputStream = TextOutputStream.Create(f)
  
  t.Write(ConvertEncoding(TextArea2.text,  Encodings.WindowsANSI))

Your code looks almost the same as the documentation example.
Nothing jumps out.

How do you check that the result is UTF8?

Try writing the text to a binarystream instead - does that get the same issue?

[code]Dim FileName As String
Dim FinalString As String
FileName = β€œC:\TEMP\500” + β€œ.sql”

Dim stream As BinaryStream
Dim f As FolderItem = New FolderItem(fileName,FolderItem.PathTypeAbsolute)
If f <> Nil Then
stream = BinaryStream.Create(f, True) // Overwrite if exists
stream.Write(ConvertEncoding(TextArea2.text, Encodings.WindowsANSI))
stream.Close
End If[/code]

1 Like

Thanks.

With the code above, it seems that ANSI type file is created.
I check if it is by using Encoding button of Notepadd++.

However, when I try to create a file having Korean characters, those words are displayed with β€˜???’.
Do you think it is normal?
Of course, without ConvertEncoding, Korean characters are displayed correctly but its file type is UTF-8 automatically.
I need ANSI type file displaying Korean characters well.

Can you help me?

You cannot display Korean in β€œANSI” CP-1252.

https://en.wikipedia.org/wiki/Windows-1252

Yes, you are right.

I tried to convert Encoding of the original file into UTF8 to display it on a textarea, then tried to create another file to use it.
I guess that is the reason why I just see UTF8 type file when I create a file.

With BinaryStream, at least I can create a ANSI type file. Good enough for now.

Thanks.