PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • UTF8 - ANSI conversion
  • Conversion to PHP
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Converts:
  • a character string in UNICODE format into a character string in ANSI format (Windows).
  • a buffer containing a character string in UNICODE format into a buffer containing a character string in ANSI format (Windows).
Reminder:
  • ANSI is the format of characters according to the Windows standard.
  • UNICODE is a mechanism for encoding characters. The UNICODE format is used to manage the different languages and the different character sets.
Example
MyAnsiBuffer is Buffer
// Convert the MyUnicodeBuffer buffer
// that contains a character string in UNICODE format
// into a buffer containing a character string
// in ANSI format
MyAnsiBuffer = UnicodeToAnsi(MyUnicodeBuffer)
WEBDEV - Server codePHPAjax
MyUnicodeString is UNICODE string
MyAnsiString is string
FileNum is int = fOpen("c:\Temp\MyText.txt", foRead + foUnicode)
IF FileNum <> -1 THEN
MyUnicodeString = fReadLine(FileNum)
END
MyAnsiString = UnicodeToAnsi(MyUnicodeString, charsetGreek)
Syntax

Converting a Unicode character string Hide the details

<Result> = UnicodeToAnsi(<Character String to Convert> [, <Charset> [, <Unknown Character>]])
<Result>: Character string or buffer
Character string in ANSI format.
<Character String to Convert>: Unicode character string
Character string in UNICODE format to convert. This parameter can also be a character string in ANSI format that contains UNICODE characters.
<Charset>: Optional Integer constant
Character set that will be used for the conversion.
charsetAnsiRoman characters in ANSI standard
charsetArabicArabic characters
charsetBalticBaltic characters
charsetChineseChinese characters (People's Republic of China)
charsetTraditionalChineseTraditional Chinese characters (Republic of Taiwan)
charsetKoreanKorean characters
charsetCurrent
Default value
Uses the current character set specified by ChangeCharset (charsetOccidental by default)
charsetDefault
Uses the default character set defined for the computer. No character set is forced.
charsetEastEuropeCharacters of Eastern Europe (Polish, ...)
charsetGreekGreek characters
charsetHebrewHebrew characters
charsetJapaneseJapanese characters
Versions 20 and later
charsetMac
New in version 20
charsetMac
charsetMac
Characters to the Mac Roman standard (used on the old Macintosh versions).
charsetOccidentalRoman characters in ANSI standard
charsetRussianRussian characters
charsetThaiThai characters
charsetTurkishTurkish characters
charsetUTF8Used to manage the UTF8 format (used in XML for example)
charsetVietnameseVietnamese characters
<Unknown Character>: Optional character or constant
Character to use if an unknown character is found by the conversion. The NULL constant allows you to use the default system character.

Converting a buffer containing a character string in Unicode format Hide the details

<Result> = UnicodeToAnsi(<Buffer> [, <Charset> [, <Unknown Character>]])
<Result>: Buffer
Buffer containing a character string in ANSI format.
<Buffer>: Buffer
Buffer containing a character string in UNICODE format to convert. The result will be undefined if <Buffer> contains a character string in ANSI format.
<Charset>: Optional Integer constant
Character set that will be used for the conversion.
charsetAnsiRoman characters in ANSI standard
charsetArabicArabic characters
charsetBalticBaltic characters
charsetChineseChinese characters (People's Republic of China)
charsetTraditionalChineseTraditional Chinese characters (Republic of Taiwan)
charsetKoreanKorean characters
charsetCurrent
Default value
Current character set specified in ChangeCharset (charsetOccidental by default)
charsetDefault
Uses the default character set defined for the computer. No character set is forced.
charsetEastEuropeCharacters of Eastern Europe (Polish, ...)
charsetGreekGreek characters
charsetHebrewHebrew characters
charsetJapaneseJapanese characters
Versions 20 and later
charsetMac
New in version 20
charsetMac
charsetMac
Characters to the Mac Roman standard (used on the old Macintosh versions).
charsetOccidentalRoman characters in ANSI standard
charsetRussianRussian characters
charsetThaiThai characters
charsetTurkishTurkish characters
charsetUTF8Used to manage the UTF8 format (used in XML for example)
charsetVietnameseVietnamese characters
<Unknown Character>: Optional character or constant
Character to use if an unknown character is found by the conversion. The NULL constant allows you to use the default system character.
Remarks
WEBDEV - Server codePHPAjax

UTF8 - ANSI conversion

To convert an ANSI string into a string in UTF8 format, use StringToUTF8.
To convert a UFT8 string into a string in ANSI format, use:
PHP

Conversion to PHP

The conversion performed in PHP is using the following PHP extensions:
  • the php_iconv.dll extension
  • the php_mbstring.dll extension
If none of these PHP extensions is found, only the Latin characters will be converted (the Chinese or Russian characters will not be converted for example).
The php_iconv.dll and php_mbstring.dll extensions are currently proposed on the PHP servers. To find out whether these extensions are proposed by your hosting company, enter the following information in a search engine: phpinfo <Name of hosting company>.
To install these extensions on your own PHP server, all you have to do is uncomment the requested extension in the PHP.INI file.
Component : wd240vm.dll
Minimum required version
  • Version 9
This page is also available for…
Comments
PARA RESOLVER PROBLEMAS DE ACENTUAÇÃO
Prezados,

Caso de problema com acentuação, use:

retorno is string = UFT8toString(textocomacento)

USE O COMANDO UTF8ToString OU AnsiToUnicode


ProcedureWS_Android_IOS_HTTPGetResult()

// Variable
bufResHTTP is Buffer
sHTTPResult isstring

// Retrieves the result of the query
bufResHTTP=HTTPGetResult(httpResult)

// Result in UTF8 em iOS Apple
IFIniOSMode() =TrueORIniOSSimulatorMode() =TrueORIniOSEmulatorMode() =True
IFStringCount(bufResHTTP, “ISO-8859-1”,IgnoreCase) =0THEN
sHTTPResult=UTF8ToString(bufResHTTP)
ELSE
sHTTPResult=AnsiToUnicode(bufResHTTP)
END
ELSE IFInAndroidMode() =TrueORInAndroidSimulatorMode() =TrueORInAndroidEmulatorMode() =True
// Result in Android
sHTTPResult=bufResHTTP
END

RESULTsHTTPResult
adrianoboller
Mar. 24 2016