?
Solved

CSV and Multilingual Characters Problem

Posted on 2003-03-03
1
Medium Priority
?
339 Views
Last Modified: 2010-03-31
Hi, i am trying to write a program that creates an xml and a csv file, given a set of data.... i have no problem displaying the contents of the xml that i have written, the problem is my csv file.... microsoft excel 2000 could not open the file properly, it only displays garbage in the place of the multilingual characters... i have installed a language pack for my operating system (Win2K advanced server)....

below is my code for writing the data:

*** xml writer *****

import java.io.*;

public class XMLWrite {

  public static void main(String[] args) {
    try {
      BufferedWriter bw =
          new BufferedWriter(
              new OutputStreamWriter(
                  new FileOutputStream("C:\\test\\test.xml"), "UTF8"));
      bw.write("<data>");
      bw.newLine();
      bw.write("<line>" + "\u1116\u1126\u1136\u1146" + "</line>");
      bw.newLine();
      bw.write("<line>" + "\u1146\u1126\u1136\u1116" + "</line>");
      bw.newLine();
      bw.write("</data>");
      bw.newLine();
      bw.flush();
      bw.close();

    }
    catch (Exception ex) {

    }
  }

}


*** csv writer *****

package experiment;

/**
 * Title:
 * Description:
 * Copyright:    Copyright (c) 2003
 * Company:
 * @author
 * @version 1.0
 */

import java.io.*;

public class Write {

  /**
   *
   */
  public static void main(String[] args) {
    try {
      BufferedWriter bw =
          new BufferedWriter(
              new OutputStreamWriter(
                  new FileOutputStream("C:\\test\\test.csv"), "UTF8"));
      bw.write("1,1,\u1116\u1126\u1136\u1146");
      bw.newLine();
      bw.write("2,2,\u1116\u1126\u1136\u1146");
      bw.newLine();
      bw.flush();
      bw.close();

    }
    catch (Exception ex) {

    }
  }

}
0
Comment
Question by:spoj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
cd1 earned 600 total points
ID: 8210234
I think you will find that CSV format does not support multibyte character sets.  For instance try entering your multibyte characters into excel and saving it as a csv file.  Excel complains and suggests using another format.
If CSV were to support multibyte encoding, which one? UTF8, BIG-5 etc.  The reason that XML handles it is that the XML specification allows you to define the encoding scheme (if not it defaults to UTF-8).
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question