PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV Mobile 2024 → ansi or unicode format
ansi or unicode format
Iniciado por JOHNKEN, nov., 20 2014 2:41 PM - 16 respostas
Membro registado
26 mensagems
Publicado em novembro, 20 2014 - 2:41 PM
How to detect if the text file you are accessing/opening is ansi or unicode format?
Publicado em novembro, 20 2014 - 3:04 PM
Hi

When you load it in a buffer variable, the first 2 bytes contains a
specific value in UNICODE mode. Be careful that there are several
variants of Unicode (little endian, big endian...), so there may be
several different header value to test.

You can of course check that out by using an Hexadecimal editor on your
files

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXReplication, your open source replication system is available on
my web site!!!
WXShowroom.com: Show your projects!
More information on http://www.fabriceharari.com


On 11/20/2014 8:41 AM, JOHNKEN wrote:
How to detect if the text file you are accessing/opening is ansi or
unicode format?
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em novembro, 20 2014 - 3:20 PM
Procedure WS_Android_IOS_HTTPGetResult()

// Variable
bufResHTTP is Buffer
sHTTPResult is string

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

// Result in UTF8 em iOS Apple
IF IniOSMode() = True OR IniOSSimulatorMode() = True OR IniOSEmulatorMode() = True
IF StringCount(bufResHTTP, “ISO-8859-1, IgnoreCase) = 0 THEN
sHTTPResult = UTF8ToString(bufResHTTP)
ELSE
sHTTPResult = AnsiToUnicode(bufResHTTP)
END
ELSE IF InAndroidMode() = True OR InAndroidSimulatorMode() = True OR InAndroidEmulatorMode() = True
// Result in Android
sHTTPResult = bufResHTTP
END

RESULT sHTTPResult
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em novembro, 20 2014 - 3:28 PM
JOHNKEN

I work with Windev Mobile set IN [x] ANSI GLOBAL project

I had to make this overall Procedure for making the identification was coming up the RETURN of the HTTPRequest with Unicode OR ANSI IN HTTPGetResult, I stopped using the standard command after the HTTPRequest AND I Use mine AND have had success.

Using my example Above Procedure:

url = "br.linkedin.com/in/adrianoboller"

ok is boolean = HTTPRequest (Url)

IF ok = True

RETURN is string = WS_Android_IOS_HTTPGetResult()

END

Came No more Japanese, Korean OR Chinese code AND thus... rssss.... :)
Membro registado
26 mensagems
Publicado em novembro, 20 2014 - 4:08 PM
Thanks for the reply guys...

another question, Im using windows ce device and want to read a text file copied to the device.
how will i determine automatically if that file is in ansi or unicode format.
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em novembro, 20 2014 - 9:39 PM
Same Technique

IF StringCount(bufResHTTP, “ISO-8859-1, IgnoreCase) = 0 THEN
RESULT = UTF8ToString(TextBuffer)
ELSE
RESULT = AnsiToUnicode(TextBuffer)
END
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em novembro, 20 2014 - 9:40 PM
Procedure LE_ASCII(LOCAL ArquivoTxt)

//Le arquivo texto

// Declare the variables
PathFile is string = ArquivoTxt
IdFile, ResCloseFile, FileID, NumeroLinha is int
Line is string

// Open the file
FileID = fOpen(PathFile,foReadWrite)
IF IdFile = -1 THEN
Error(ErrorInfo(errMessage))
ELSE

//Converte de Unicode para Ansi
Line = UnicodeToAnsi(fReadLine(FileID))

//Linha 1
NumeroLinha = 1
//Info("Linha:" + NumeroLinha, Line)

WHILE Line <> EOT AND Line <> ""

//Proxima linha
NumeroLinha += 1
Line = fReadLine(FileID)
//Info("Linha:" + NumeroLinha, Line)

END
IF Line = "" THEN Error(ErrorInfo(errMessage))
IF Line = EOT THEN Info("Final do Arquivo.")
ResCloseFile = fClose(IdFile)
IF ResCloseFile = -1 THEN
//Error(ErrorInfo(errMessage))
END

END
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em novembro, 20 2014 - 9:44 PM
Change your project globally to ANSI

P (Big Yellow) -> popup Mouse Right -> Project Description -> Down Button: [ DESCRIBING THE CURRENT CONFIGURATION ] -> Guia Aba: UNICODE -> Check [x] ANSI -> OK -> OK

Re-test code... ok
Publicado em novembro, 20 2014 - 9:54 PM
Hi

in what exactly is that another question? This looks exactly like the
one I already answered to...

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXReplication, your open source replication system is available on
my web site!!!
WXShowroom.com: Show your projects!
More information on http://www.fabriceharari.com


On 11/20/2014 10:08 AM, JOHNKEN wrote:
Thanks for the reply guys...
another question, Im using windows ce device and want to read a text
file copied to the device.
how will i determine automatically if that file is in ansi or unicode
format.
Membro registado
26 mensagems
Publicado em novembro, 21 2014 - 5:31 AM
thanks adrianoboller,
got it already
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em novembro, 21 2014 - 1:27 PM
JOHNKEN

But he succeed?

If not send me a mini project to try to help you...

Att

Adriano
Membro registado
26 mensagems
Publicado em novembro, 21 2014 - 3:25 PM
Hi Adriano,

I did it but its separate process for ansi and unicode file.

here is my sample project
https://www.dropbox.com/s/obuuq0q4pu5oqlh/AnsiUnicode.rar…
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em novembro, 22 2014 - 12:50 PM
Ok I will look today and give you a return
Max until Monday

:merci:
Publicado em fevereiro, 19 2022 - 1:31 PM
If you need to migrate your ansi file to unicode, then there is a manual method where you have to configure your ansi to your unicode via Import/export feature and then import your ansi file. You can also transfer your file through ansi To unicode Migration Tool and transfer your data easily.

Visit at : https://www.osttopstapp.com/ansi-to-unicode-pst.html
Membro registado
53 mensagems
Publicado em fevereiro, 23 2022 - 10:43 AM
hi,
I tried to use your procedure for maneg a respons from a websevice that has been giving me problems for some time to IOS, your solution works in the emulator but not on a real IOS smartphone.
Have you ever tested it in production?

Procedure WS_Android_IOS_HTTPGetResult()

// Variable
bufResHTTP is Buffer
sHTTPResult is string

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

// Result in UTF8 em iOS Apple
IF IniOSMode() = True OR IniOSSimulatorMode() = True OR IniOSEmulatorMode() = True
IF StringCount(bufResHTTP, “ISO-8859-1”, IgnoreCase) = 0 THEN
sHTTPResult = UTF8ToString(bufResHTTP)
ELSE
sHTTPResult = AnsiToUnicode(bufResHTTP)
END
ELSE IF InAndroidMode() = True OR InAndroidSimulatorMode() = True OR InAndroidEmulatorMode() = True
// Result in Android
sHTTPResult = bufResHTTP
END

RESULT sHTTPResult


I haven't found a solution to my problem for months and your help would be greatly appreciated.

thanks
Mensagem modificada, fevereiro, 23 2022 - 10:43 AM
Membro registado
4 mensagems
Publicado em fevereiro, 25 2022 - 1:41 PM
the first 2 bytes contains a
specific value in UNICODE mode. Be careful that there are several
variants of Unicode (little endian, big endian...), so there may be
several different header value to test.

You can of course check that out by using an Hexadecimal editor on your
files.
Membro registado
4 mensagems
Publicado em fevereiro, 25 2022 - 1:45 PM
Be careful that there are several
variants of Unicode (little endian, big endian...), so there may be
several different header value to test.

You can of course check that out by using an Hexadecimal editor on your
files