#include once "window9.bi"

Function ASCIITOUTF(ByRef text As String) As WString Ptr Export
	If text<>"" Then
		Var blen = (Len(text)*2)+2
		Dim As WString Ptr wbuf
		wbuf  = Allocate( blen )
		if wbuf then
			MultiByteToWideChar(CP_ACP, 0,StrPtr(text) , -1, wbuf, blen)
		endif
		Return  wbuf
	EndIf
End Function

Function UTFTOASCII(ByVal text As WString Ptr) As String Export
	Var    blen = WideCharToMultiByte (CP_ACP  , 0,text , -1, 0, 0,0,0)
	Dim As ZString ptr wbuf
	Dim As String returnS
	wbuf= allocate( blen )
	if wbuf then
		WideCharToMultiByte (CP_ACP  , 0,text , -1, Cast( LPSTR ,wbuf), blen,0,0)
		returnS=*wbuf
		DeAllocate(wbuf)
	endif
	Return returnS
End Function
