Java Is Latin String isLatinString(final String str)

Here you can find the source of isLatinString(final String str)

Description

is Latin String

License

Open Source License

Declaration

public static boolean isLatinString(final String str) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016, 2017 Trig Chen.//ww w .jav  a2  s.c  o m
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Trig Chen - initial API and implementation
 *******************************************************************************/

import java.io.UnsupportedEncodingException;

public class Main {
    public static boolean isLatinString(final String str) {

        try {
            return str.equals(new String(str.getBytes("ISO-8859-1"),
                    "ISO-8859-1"));
        } catch (final UnsupportedEncodingException e) {
            return false;
        }
    }
}