Android Charset Get getLocaleCharset(String locale)

Here you can find the source of getLocaleCharset(String locale)

Description

get Locale Charset

License

Open Source License

Declaration

public static Charset getLocaleCharset(String locale) 

Method Source Code

//package com.java2s;
/**//from   w w w  .  j  av a 2 s.  c o  m
 * This file is part of LoLin1.
 * <p/>
 * LoLin1 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * <p/>
 * LoLin1 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.
 * <p/>
 * You should have received a copy of the GNU General Public License
 * along with LoLin1. If not, see <http://www.gnu.org/licenses/>.
 * <p/>
 * Created by Jorge Antonio Diaz-Benito Soriano on 03/01/14.
 * <p/>
 * Accessing resources through reflection is said to be ten times faster than through getResources(), and thus it's done when possible.
 */

import java.nio.charset.Charset;

import java.util.HashMap;

import java.util.Map;

public class Main {
    private static final Map<String, Charset> charsetMap = new HashMap<>();

    public static Charset getLocaleCharset(String locale) {
        return charsetMap.containsKey(locale) ? charsetMap.get(locale)
                : Charset.forName(locale);
    }
}

Related

  1. getCharset(String enc)
  2. isCharsetSupported()