Convert a string from ISO-8859-1 to UTF-8

Use this handy LotusScript function to convert a string from ISO-8859-1 to UFT-8.
Appcelerator • Appcelerator Alloy • LotusScript • XML


Function UTF8(s$) As String
	
	For i% = 1 To Len(s$)
		u& = Uni(Mid$(s$, i%, 1))
		If u& < &H80 Then
			r$ = r$ & Uchr$(u&)
		Elseif u& < &HC0 Then
			r$ = r$ & Uchr$(&HC2) & Uchr$(u&)
		Elseif u& < &H100 Then
			r$ = r$ & Uchr$(&HC3) & Uchr$(u& - &H40)
		Else
			Error 1000, "Character is not in ISO-8859-1"
		End If
	Next
	UTF8 = r$
	
End Function

Written by Geoffrey Laurent

Posted by fbrefere001 on Sunday June 7, 2015