Java String Normalize normalize(final String string)

Here you can find the source of normalize(final String string)

Description

Normalizes the given string (which must be encoded into UTF-8) in order that the result contains only unified chars.

License

Open Source License

Parameter

Parameter Description
string the string to normalize. There is no guarantee when the string is not encoded into UTF8.

Return

the normalized string.

Declaration

public static String normalize(final String string) 

Method Source Code

//package com.java2s;
/*//from   w w w . ja v a2s . c om
 * Copyright (C) 2000 - 2018 Silverpeas
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * As a special exception to the terms and conditions of version 3.0 of
 * the GPL, you may redistribute this Program in connection with Free/Libre
 * Open Source Software ("FLOSS") applications as described in Silverpeas's
 * FLOSS exception.  You should have received a copy of the text describing
 * the FLOSS exception, and it is also available here:
 * "https://www.silverpeas.org/legal/floss_exception.html"
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.text.Normalizer;

public class Main {
    /**
     * Normalizes the given string (which must be encoded into UTF-8) in order that the result
     * contains only unified chars.
     * <p>Indeed, according to the environment of the user, sometimes it is sent data with
     * combined characters which will make the server have a bad behavior, like throw an error on
     * file download.</p>
     * @param string the string to normalize. There is no guarantee when the string is not encoded
     * into UTF8.
     * @return the normalized string.
     */
    public static String normalize(final String string) {
        String normalized = string;
        if (normalized != null) {
            normalized = Normalizer.normalize(normalized, Normalizer.Form.NFC);
        }
        return normalized;
    }
}

Related

  1. normaliseConll(String input)
  2. normaliseUnicode(String unicodeText, char[] mappings)
  3. normalize(final String input)
  4. normalize(final String s)
  5. normalize(final String s)
  6. normalize(final String string)
  7. normalize(Object o, StringBuffer sb)
  8. normalize(String adoc)
  9. normalize(String in)