Jump to content

Converting files on UDF 8 Pure


 Share

Recommended Posts

Text translated from Portuguese by google - please apologize for any errors

Hello I would like to know where I am going wrong and how to fix this simple program.

The problem is this, I'm in Brazil and use the portuguese language that contains accented characters.

When I use the editor SciTE autoit (which is very good) I have no problems.

However to develop more complex programs I like to use an old program called "Autoit Debugger" for lack of anything better.

It works fine until I use accented characters like "ç", "ã", "é" etc.

When you open any file generated by SciTE in "Debugger" coding becomes US-ASCII and all accented characters disappear on the display but the bytes exist, secretly, generating unpredictable errors during debugging.NormalSciTE.JPG

I've tried changing the SciTE coding for UDF-8 and even then the "Debugger" US-ASCII encoding

When I save the same file through the Notepad  "Debugger" encoding "Western European (Windows)" that although display the characters also problems.

 

Noutpad-UDF8.JPG

I know someone can say ... that the problem is with the "Debugger" and the developer who has to solve this but this is impossible (I've tried no return).

With this imagined creating a little program to open any file and convert to UDF-8 using "FileOpen" mode 256

 

 

Global $Contato = @CRLF & _ ;quebra a linha para ficar em baixo
        "A automao da automao criado por:" & @CRLF & _  ;Nome da empresas (site)
        "www.roboautomato.com.br (em construo)" & @CRLF & _     ; Cel
        "Skype: junior.prof" & @TAB & _                 ; Dados do meu skype
        "Fone:  +55 (11) 9-9372-0074 TIM" & @CRLF & _       ; Cel
        "www.facebook.com/roboautomato" & @TAB & _      ; Cel
        "E-mail: junior.prof@yahoo.com.br" ; e-mail
;15/11/26 Musança da sequencia pois assim é mais logico
Global $ArqGravacao, _ ;contem os dados do arq de grava��o
        $ArqAbertoGravacao, _ ;Buter do arqiovo Aberto ou Handle
        $ArqQuantGravacao, _    ;Total de Bytes do arquivo de Leituta
        $ArqPosGravacao, _      ;Posi��o atual do arquivo em Bytes
        $ArqLinhaGravacao ;Linha atual do arquivo de leitura
Global $ArqLeitura, _           ;contem os dados do arq de leitura
        $ArqAbertoLeitura, _    ;Buter do arqiovo Aberto ou Handle
        $ArqQuantLeitura, _     ;Total de Bytes do arquivo de Leituta
        $ArqPosLeitura, _       ;Posi��o atual do arquivo em Bytes
        $ArqLinhaLeitura ;Linha atual do arquivo de leitura
#endregion Variaveis de Arquivos e pastas

#region --- Internal functions Au3Recorder Start ---


;1 Localizar arquivo

$ArqLeitura = FileOpenDialog("Localiza o arquivo", @ScriptDir & "", "Autoit Files (*.au3)|Todos (*.*)", 1 + 4)
If @error Then
    MsgBox(Default, _; flag
            "Cancelado o Programa ", _;"title"
            "O arquivo  ( " & $ArqLeitura & " ) não existe ou não esta disponivel" & @CRLF & _
            "Ação:Abertura do Arquivo nao UDF8" & @CRLF & _
            "Quarquer duvida entrar em contato" & @CRLF & _
            $Contato, _ ; "text"
            5, _        ;[, timeout
            Default);[, hwnd]])
    
    Exit
EndIf
$ArqAbertoLeitura = FileOpen($ArqLeitura, 16);leitura Binario
;define o nome de gravacao
; pegar a pasta melhorar
Local $sDir_Name = StringRegExpReplace($ArqLeitura, "(^.*\\)(.*)", "\1")
Local $NomeArq = StringRegExpReplace($ArqLeitura, "^.*\\", "")
Local $NomeArqPos = StringInStr($NomeArq, ".", 0, -1);localiza o ponto da extensão
Local $NomeArq2 = StringLeft($NomeArq, $NomeArqPos - 1)
Local $NomeArqExt = StringRight($NomeArq, StringLen($NomeArq) - $NomeArqPos)
$ArqGravacao = $sDir_Name & $NomeArq2 & "UDF8." & $NomeArqExt
If FileExists($ArqGravacao) Then
    
    #region --- CodeWizard generated code Start ---
    ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Question
    If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
    $iMsgBoxAnswer = MsgBox(36, "Substituir o arquivo...", "O Arquivo [" & $ArqGravacao & "] ja existe deseja subistitui-lo (S/N)")
    Select
        
        Case $iMsgBoxAnswer = 7 ;No
            MsgBox(Default, _; flag
                    "Cancelado o Programa ", _;"title"
                    "O arquivo  ( " & $ArqGravacao & " ) já existe" & @CRLF & _
                    "Ação:Já existe UDF8" & @CRLF & _
                    "Quarquer duvida entrar em contato" & @CRLF & _
                    $Contato, _ ; "text"
                    5, _        ;[, timeout
                    Default);[, hwnd]])
            Exit
    EndSelect
    FileDelete($ArqGravacao)
    #endregion --- CodeWizard generated code Start ---
EndIf

$ArqAbertoGravacao = FileOpen($ArqGravacao, 259);Gravação UDF8 sem BOM e sobreescrito 256+1+2
If $ArqAbertoGravacao = -1 Then
    ;Caso Verdade erro de abertura
    BlockInput(0); desbloqueia o usuario
    MsgBox(Default, _; flag
            "Cancelado o envio ", _;"title"
            "O arquivo  ( " & $ArqGravacao & " ) não existe ou não esta disponivel" & @CRLF & _
            "Ação:Gravando dados de fabrica" & @CRLF & _
            "Quarquer duvida entrar em contato" & @CRLF & _
            $Contato, _ ; "text"
            5, _        ;[, timeout
            Default);[, hwnd]])
    FileClose($ArqAbertoGravacao)
    ;       FileDelete($ArqGravacao)
    Exit
EndIf
    
If $ArqAbertoLeitura = -1 Then
    ;Caso Verdade erro de abertura
    BlockInput(0); desbloqueia o usuario
    MsgBox(Default, _; flag
            "Cancelado o envio ", _;"title"
            "O arquivo  ( " & $ArqLeitura & " ) não existe ou não esta disponivel" & @CRLF & _
            "Ação: Abertura da Lista de Contatos" & @CRLF & _
            "Quarquer duvida entrar em contato" & @CRLF & _
            $Contato, _ ; "text"
            5, _        ;[, timeout
            Default);[, hwnd]])
    Exit
Else
    $iLineNumber = 0
    $Dimen = 0
    $VarAtual = ""
    While True
        $iLineNumber += 1
        $sCurrentLine = FileReadLine($ArqAbertoLeitura) ; , $iLineNumber)
        If @error = -1 Then ExitLoop ;acabou o arquivo então sai
        ;if $sCurrentLine<>"" Then
        ;obtem os dados da linha
        $sBinary = StringToBinary($sCurrentLine)
        ;MsgBox(Default, _; flag
            ;"Linha ["& $iLineNumber  &"] ", _;"title"
            ;"[" & $sCurrentLine & "]" & @CRLF & _ 
            ;"["& $sBinary &"]" & @CRLF & _ 
            ;"["& BinaryToString( $sBinary,4) &"]", _
            ;15, _      ;[, timeout
            ;Default);[, hwnd]])
        $StringLine=    BinaryToString( $sBinary,4)
        FileWriteLine($ArqAbertoGravacao,$StringLine)
        
    WEnd
    FileClose($ArqAbertoLeitura)
    FileClose($ArqAbertoGravacao)
EndIf

 

 

 

He did not change.

The question is, how to generate a file UDF-8 plain text.

PS miraculously have a UDF8 file to replicate can keep this encoding within the Debugger and paste the text I use without problems.

 

 

Edited by odaylton
Link to comment
Share on other sites

  • 9 months later...
  • 7 months later...

try replace with this

# Internationalisation
NewFileEncoding=UTF8BOM         # Only available in SciTE4AutoIt3 version

#~ Enhance function of auto checking utf8: providing two methods
# detect utf8 and add BOM automatically   Credits to SciTE-RU
utf8.auto.check=1
# detect utf8 and do not add BOM
#~ utf8.auto.check=2
# detect ascii high characters and if none found set default encoding to UTF8 and add BOM
#~ utf8.auto.check=3
# detect ascii high characters and if none found set default encoding to UTF8 and do not add BOM
# utf8.auto.check=4

# Japanese input code page 932 and ShiftJIS character set 128
#code.page=932
#character.set=128
# Unicode
code.page=65001
#~ code.page=0
#character.set=204
#command.discover.properties=python /home/user/FileDetect.py "$(FilePath)"
# Required for Unicode to work on GTK+:
#LC_CTYPE=en_US.UTF-8
if PLAT_WIN
    output.code.page=0
if PLAT_GTK
    output.code.page=65001
if PLAT_MAC
    output.code.page=65001

in SciTEGlobal.properties

tell me if you still have this problem

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...