Howto convert UTF8 To ISO-8859-1 ?

BlitzMax Forums/BlitzMax Beginners Area/Howto convert UTF8 To ISO-8859-1 ?

Difference(Posted 2005) [#1]
Is there by any chance a builtin function to do this?

I'm using expat ( expat.sourceforge.net/ ) and it converts evertything into UTF8, but I need the data to stay in the ISO-8859-1 charset.


FlameDuck(Posted 2005) [#2]
Is there by any chance a builtin function to do this?
No. There ought to be though. IMHO.

The best way to do this would be to extend TStream (ala. EndianStreams), but if you don't want to write your own, and continue using expat (libxml2 based?) you could maybe use a third party tool or library?


Difference(Posted 2005) [#3]
I've ended up using libxml2 for the whole thing.
It too converts to UTF8 , but it has a conversion function:
Strict
Const  DllName:String = "libxml2.dll"
Local DllHandle = LoadLibraryA(DllName)
Global 	UTF8Toisolat1(out:Byte Ptr, outlen:Int Var, in:Byte Ptr, inlen:Int Var )= GetProcAddress(DllHandle,"UTF8Toisolat1")

Function UTF82LAT1$(in$)
	
	Local inlen,outlen

	inlen = Len(in)

	Local outbank:TBank = CreateBank(Len(in))
		
	outlen = BankSize(outbank)
		
	If UTF8Toisolat1 (BankBuf(outbank) ,outlen ,in,inlen )>=0		
		Return Left$(string.fromcstring(BankBuf(outbank) ),outlen )
	Else	
		Return in$		
	EndIf
	
End Function