Convert WriteStream into UTF8?

Started by Yellownakji, May 16, 2019, 13:52:21

Previous topic - Next topic

Yellownakji



Global TotalGlyphs:Int = 65535 'Total ASCII
Global OnGlyph:Int = 0
Global File:TStream

CreateFile("Glyphs.txt")
File = OpenStream("Glyphs.txt", False, True)

Repeat
WriteLine(File, Chr(OnGlyph))
OnGlyph = OnGlyph + 1
'Print Asc("무")
Until OnGlyph = TotalGlyphs

CloseStream(File)


This little snippit prints out every ASCII character, however incorrectly.   Around the 23k mark, characters will repeat themselves simply because the stream is writing to ANSI format.  Can i get the stream to output as UTF8, so that all the glyphs are properly written?

TomToad

The glyphs are being properly written in 16 bit unicode.  Most likely, the program you are opening up the resulting file in is expecting UTF-8.  If you want to output UTF-8, you can use a TextStream and specify UTF8 in the format.
SuperStrict
Local Stream:TStream = WriteStream("utf8::MyFile.txt")
For Local i:Int = 0 To 65535
WriteLine(Stream,Chr(i))
Next
CloseStream Stream

------------------------------------------------
8 rabbits equals 1 rabbyte.