Java UTF8 decUTF8(String s)

Here you can find the source of decUTF8(String s)

Description

dec UTF

License

Open Source License

Declaration

private static String decUTF8(String s) 

Method Source Code

//package com.java2s;
/**/*from w  w  w.j  a v a2  s . c o  m*/
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  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 General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @author Kevin Smith, Boundless, 2017
 */

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import java.nio.charset.StandardCharsets;

public class Main {
    private static String decUTF8(String s) {
        try {
            // This would be much nicer if URLDecoder.decode took a charset object instead of a string
            return URLDecoder.decode(s, StandardCharsets.UTF_8.name());
        } catch (UnsupportedEncodingException e) {
            throw new IllegalStateException("Standard encoding UTF-8 is missing");
        }
    }
}

Related

  1. createFromUTF8String(DatagramPacket packet, String str)
  2. createTemporaryOutputFolder()
  3. decodePayloadFromUtf8(String utf8string)
  4. decodeUTF8(byte[] bytes)
  5. decodeUtf8(String url)
  6. dumpStringArray(Path outputFilePath, String[] stringArray)
  7. dumpUtf8ToFile(List records, String delimiter, File file)
  8. fromUTF8(byte[] ba)
  9. fromUTF8(byte[] bytes)