Problemas ao converter de Hexa para char

0 respostas
P

Amigos, tenho uma rotina que converte hexa para char.

public String convertHex (String pText) throws Exception
{
    alert(pText);
	if (pText.length() > 2 && pText.substring(0, 2).equals("0x"))
    {
        String wBuffer = "";

        // Ignores the first 2 characters   
        pText = pText.substring(2); 

        // Converts Hex to String
        for (int i = 0; i < pText.length(); i = i + 2)
		{
            wBuffer = wBuffer + (char) Integer.parseInt( pText.substring( i, i + 2  ), 16 );
            alert(wBuffer);
	    }
                
        return new String (wBuffer.getBytes(), "ISO-8859-1");
    }
    else
    {
       return pText; 
    }     
}

Mas esta acontecendo alguns problemas quando as palavras tem acentos ou "ç". Vou dar exemplos:

CONVERTIDO ORIGINAL
CAMBÉ (EAR CABUNI cb CAB04) CAMBÉ (EAR CABUNI CB CAB04)
SÃO FRANCISCO - EXPOSIÇÃO SÃO FRANCISCO - EXPOSIÇÃO

alguem sabe o porque ou tem alguma dica de como fazer essa conversão correta?

Agradeço desde já.

Criado 31 de agosto de 2006
Respostas 0
Participantes 1