Skip to content

Instantly share code, notes, and snippets.

@dilnei
Created August 6, 2014 17:26
Show Gist options
  • Select an option

  • Save dilnei/d1aca2e4d1e4c1641b60 to your computer and use it in GitHub Desktop.

Select an option

Save dilnei/d1aca2e4d1e4c1641b60 to your computer and use it in GitHub Desktop.
Métodos para tratamento de encoding
package br.com.risingforce.helper;
import java.text.Normalizer;
/**
* <b>Classe que contém métodos para tratamento de encoding.</b>
*
* @author Dilnei Cunha.
*/
public class UTF8 {
/**
* <b>Método responsável por remover os caracteres não UTF-8.</b>
*
* @param texto
* @return String
*/
public static String removeNaoUTF8(String texto) {
texto = Normalizer.normalize(texto, Normalizer.Form.NFD);
texto = texto.replaceAll("[^\\p{ASCII}]", "");
return texto;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment