Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CSV and Multilingual Characters Problem

Posted on 2003-03-03
1
Medium Priority
?
352 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
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

579 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