Problemas com encoder de arquivo ?[RESOLVIDO]  XML
Índice dos Fóruns » Java Avançado
Autor Mensagem
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

Já tentei usar das seguintes formas :



Só que ambos estão me gerando a seguinte saída :

S?o Paulo

alguém poderia me ajudar ?

desde já agradeço !

This message was edited 2 times. Last update was at 07/07/2011 14:56:25


"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

JoaoBluSCBR
JavaEvangelist
[Avatar]

Membro desde: 18/11/2010 15:53:29
Mensagens: 474
Localização: Blumenau (SC)
Offline

E qual o formato do teu arquivo?

Faça a leitura e veja os valores dos caracteres especial, como estão saindo;

Daí fica mais fácil saber oque está acontecendo.

Dias atrás estava com esse problema, e estava usando o charset no readLine, não funcionava.

Coloquei no FileInput e beleza, talvez no teu caso tenha que colocar no readLine.


Venci !!! Acessei um webservice usando J2ME com ksoap e kxml. kkkkkk
[Email] [MSN]
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

JoaoBluSCBR wrote:E qual o formato do teu arquivo?

Faça a leitura e veja os valores dos caracteres especial, como estão saindo;

Daí fica mais fácil saber oque está acontecendo.

Dias atrás estava com esse problema, e estava usando o charset no readLine, não funcionava.

Coloquei no FileInput e beleza, talvez no teu caso tenha que colocar no readLine.



Meu arquivo é um TXT no formato ASCII, como você fez o charset no fileInput, pode dar um exemplo ?

"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

matheuslmota
Virtual Machine Man

Membro desde: 09/03/2010 15:14:56
Mensagens: 664
Offline

Supondo que exista a String "São Paulo" no seu arquivo, o seguinte código mostrou a string corretamente:

This message was edited 1 time. Last update was at 07/07/2011 14:16:24


Toda vez que você alimenta um troll uma foca morre no Polo Norte.
[MSN]
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

matheuslmota wrote:Supondo que exista a String "São Paulo" no seu arquivo, o seguinte código mostrou a string corretamente:


Usou algum encoder ?

"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

matheuslmota
Virtual Machine Man

Membro desde: 09/03/2010 15:14:56
Mensagens: 664
Offline

Usei não. Testou ai?

Toda vez que você alimenta um troll uma foca morre no Polo Norte.
[MSN]
matheuslmota
Virtual Machine Man

Membro desde: 09/03/2010 15:14:56
Mensagens: 664
Offline

O código que você passou inicialmente no post é o código correto para ler arquivos com encoding. Você tem certeza que o enconding é ASCII mesmo? A seguinte linha de código ler um arquivo de texto usando codifição ASCII. Veja se funciona:

Toda vez que você alimenta um troll uma foca morre no Polo Norte.
[MSN]
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

matheuslmota wrote:Usei não. Testou ai?



Da forma que você postou provocou o seguinte resultado :

S?o Paulo

Mas dessa forma funcionou perfeitamente no formato .SQL ASCII



Obrigado !

"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

matheuslmota
Virtual Machine Man

Membro desde: 09/03/2010 15:14:56
Mensagens: 664
Offline

Metaleiro wrote:
matheuslmota wrote:Usei não. Testou ai?



Da forma que você postou provocou o seguinte resultado :

S?o Paulo

Mas dessa forma funcionou perfeitamente no formato .SQL ASCII



Obrigado !


Tenta usar da forma que eu coloquei no meu último post par ver se funciona para ASCII puro.

Toda vez que você alimenta um troll uma foca morre no Polo Norte.
[MSN]
matheuslmota
Virtual Machine Man

Membro desde: 09/03/2010 15:14:56
Mensagens: 664
Offline

Cara, lembrei agora que o ASCII puro não aceita caracteres acentuados. Não iria conseguir ler nunca. Para ler caracteres acentuados você deve usar o encoding ISO-8859-1 (E seu arquivo deve ter sido gravado com tal).
Abs.

Toda vez que você alimenta um troll uma foca morre no Polo Norte.
[MSN]
Metaleiro
Virtual Machine Man
[Avatar]

Membro desde: 06/07/2006 10:55:54
Mensagens: 671
Localização: São Bernardo do Campo - SP
Offline

Obrigado pelas respostas, foram de grande ajuda !

"Why, Mr. Anderson? Why do you do it? Why get up? Why keep fighting? Do you believe you're fighting for something? For more than your survival? Can you tell me what it is? Do you even know? Is it freedom? Or truth? Perhaps peace? Yes? No? Could it be for love? Illusions, Mr. Anderson. Vagaries of perception. The temporary constructs of a feeble human intellect trying desperately to justify an existence that is without meaning or purpose. And all of them as artificial as the Matrix itself, although only a human mind could invent something as insipid as love. You must be able to see it, Mr. Anderson. You must know it by now. You can?t win. It?s pointless to keep fighting. Why, Mr. Anderson? Why? Why do you persist?"

Neo :
-Because is my choice

matheuslmota
Virtual Machine Man

Membro desde: 09/03/2010 15:14:56
Mensagens: 664
Offline

Por nada, precisando, estamos ai!

This message was edited 2 times. Last update was at 08/07/2011 08:47:24


Toda vez que você alimenta um troll uma foca morre no Polo Norte.
[MSN]
 
Índice dos Fóruns » Java Avançado
Ir para:   
Powered by JForum 2.1.8 © JForum Team