Common Locale Data Repository

Java locale data


Viewing CLDR file

The CLDR files are all encoded using UTF-8 (see a later lecture). A program to display these is

import javax.swing.*;
import java.awt.*;
import java.util.ResourceBundle;

public class UTFReader {

    public static ResourceBundle bundle;

    public static void main(String[] args) throws Exception {
	bundle = ResourceBundle.getBundle("UTFReader");

	if (args.length != 1) {
	new UTFReader(args);
    public static void fatal(String errorType) {
	String errorMsg = bundle.getString(errorType);
	System.out.println("Fatal error: " + errorMsg);

    public UTFReader(String[] args) {
	FileInputStream fin = null;
	try {
	    fin = new FileInputStream(args[0]);
	} catch (FileNotFoundException e) {
        BufferedReader in = null;
	try {
	     in = new BufferedReader(new InputStreamReader(fin, "UTF-8"));
	} catch (UnsupportedEncodingException e) {

	JFrame frame = new JFrame();
	JTextArea text = new JTextArea(20, 100);
	JScrollPane pane = new JScrollPane(text);

	frame.getContentPane().add(pane, BorderLayout.CENTER);

	String s = null;
	try {
	    while ((s = in.readLine()) != null) {
		text.append(s + "\n");
	} catch (IOException e) {
	    // do nothing	    
wuth error messages in e.g.

Usage=Usage: java UTFReader <filename>
FileNotFound: File not found
NoEncoding: Cannot decode file format

On my system, the following terminal will also allow UTF fonts to be viewed

LANG=en_GB.utf8 xterm -fn '-bitstream-bitstream cyberbit-medium-r-normal--0-0-0-0-c-0-iso10646-1'

Jan Newmarch <>
Last modified: Fri Mar 11 16:34:42 EST 2005
Copyright © Jan Newmarch, Monash University, 2007
Creative Commons License This work is licensed under a Creative Commons License
The moral right of Jan Newmarch to be identified as the author of this page has been asserted.