Created
August 6, 2014 17:26
-
-
Save dilnei/d1aca2e4d1e4c1641b60 to your computer and use it in GitHub Desktop.
Métodos para tratamento de encoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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