| |
Membre enregistré 26 messages |
|
| Posté le 20 novembre 2014 - 14:41 |
| How to detect if the text file you are accessing/opening is ansi or unicode format? |
| |
| |
| | | |
|
| | |
| |
| Posté le 20 novembre 2014 - 15:04 |
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? |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 613 messages |
|
| Posté le 20 novembre 2014 - 15:20 |
Procedure WS_Android_IOS_HTTPGetResult()
bufResHTTP is Buffer sHTTPResult is string
bufResHTTP = HTTPGetResult(httpResult)
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
sHTTPResult = bufResHTTP END
RESULT sHTTPResult |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 613 messages |
|
| Posté le 20 novembre 2014 - 15:28 |
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... |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 26 messages |
|
| Posté le 20 novembre 2014 - 16:08 |
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. |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 613 messages |
|
| Posté le 20 novembre 2014 - 21:39 |
Same Technique
IF StringCount(bufResHTTP, “ISO-8859-1”, IgnoreCase) = 0 THEN RESULT = UTF8ToString(TextBuffer) ELSE RESULT = AnsiToUnicode(TextBuffer) END |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 613 messages |
|
| Posté le 20 novembre 2014 - 21:40 |
Procedure LE_ASCII(LOCAL ArquivoTxt)
PathFile is string = ArquivoTxt IdFile, ResCloseFile, FileID, NumeroLinha is int Line is string
FileID = fOpen(PathFile,foReadWrite) IF IdFile = -1 THEN Error(ErrorInfo(errMessage)) ELSE
Line = UnicodeToAnsi(fReadLine(FileID))
NumeroLinha = 1
WHILE Line <> EOT AND Line <> ""
NumeroLinha += 1 Line = fReadLine(FileID)
END IF Line = "" THEN Error(ErrorInfo(errMessage)) IF Line = EOT THEN Info("Final do Arquivo.") ResCloseFile = fClose(IdFile) IF ResCloseFile = -1 THEN
END
END |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 613 messages |
|
| Posté le 20 novembre 2014 - 21:44 |
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 |
| |
| |
| | | |
|
| | |
| |
| Posté le 20 novembre 2014 - 21:54 |
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. |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 26 messages |
|
| Posté le 21 novembre 2014 - 05:31 |
thanks adrianoboller, got it already |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 613 messages |
|
| Posté le 21 novembre 2014 - 13:27 |
JOHNKEN
But he succeed?
If not send me a mini project to try to help you...
Att
Adriano |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 26 messages |
|
| Posté le 21 novembre 2014 - 15:25 |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 613 messages |
|
| Posté le 22 novembre 2014 - 12:50 |
Ok I will look today and give you a return Max until Monday
 |
| |
| |
| | | |
|
| | |
| |
| Posté le 19 février 2022 - 13:31 |
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 |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 56 messages |
|
| Posté le 23 février 2022 - 10:43 |
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.
thanksMessage modifié, 23 février 2022 - 10:43 |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 messages |
|
| Posté le 25 février 2022 - 13:41 |
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. |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 messages |
|
| Posté le 25 février 2022 - 13:45 |
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 |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 4 613 messages |
|
| Posté le 04 décembre 2025 - 00:54 |
No WINDEV Mobile, a mudança de Unicode para ANSI pode ser feita principalmente nas configurações do projeto, para alterar o comportamento padrão das strings em tempo de execução. Isso é útil para compatibilidade com serviços ou arquivos que exigem ANSI, mas lembre-se de que o WINDEV Mobile usa Unicode por padrão, e alterações podem afetar o tratamento de caracteres especiais (como em idiomas asiáticos). Aqui vai o passo a passo principal, baseado em documentações e fóruns oficiais:
Configuração Global no Projeto
Para alternar todo o projeto para usar strings ANSI em runtime: 1 Clique com o botão direito no projeto (no painel principal, representado pelo ícone amarelo grande “P”). 2 Selecione “Descrição do Projeto” (Project Description). 3 Na janela que abre, vá até a aba “Unicode”. 4 Escolha a opção “Usar strings ANSI em tempo de execução” (Use ANSI strings at runtime). 5 Confirme as alterações e recompile/teste o projeto, pois isso afeta globalmente o código. 10 5 3 Essa configuração resolve problemas como caracteres corrompidos em respostas HTTP ou arquivos de texto, especialmente em dispositivos reais (iOS ou Android), onde emuladores podem se comportar diferente. 10
Conversões Pontuais via Funções Se você não quiser alterar o projeto inteiro, use funções para converter strings específicas: • UnicodeToAnsi(): Converte uma string Unicode para ANSI. Exemplo: sANSI = UnicodeToAnsi(sUnicode). • AnsiToUnicode(): O inverso, para converter ANSI para Unicode. Essas funções são ideais para integrações com web services ou arquivos que não suportam Unicode, como em chamadas HTTP onde você carrega o resultado em um buffer e converte com base na plataforma (ex.: UTF8ToString para iOS se não for ISO-8859-1). 0 1 10
Dicas Adicionais de Usuários • Verifique o cabeçalho do arquivo (primeiros dois bytes) com um editor hexadecimal para confirmar se é Unicode (ex.: FF FE para UTF-16 LE). Em código, carregue em um buffer e teste programaticamente. • Em iOS, conversões podem falhar em dispositivos reais mesmo funcionando no emulador – teste exaustivamente. • Para arquivos locais (ex.: em Windows CE), use fOpen e leia linhas convertendo com UnicodeToAnsi. • Há exemplos de projetos de amostra compartilhados em fóruns para lidar com ANSI/Unicode separadamente. 10 Se precisar de mais detalhes ou código específico, forneça o contexto do seu projeto (versão do WINDEV Mobile, plataforma alvo)!
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 99949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.com.br/ |
| |
| |
| | | |
|
| | |