java -utf8

Discussion in 'Java' started by M, Dec 30, 2003.

  1. M

    M Guest

    I got a program in which i write a vrml file, i thus need it encoded into
    utf8, but i don't know how to do it?
    Thanks for your help.

    M.

    File sortie = new File(".../b.vrml");
    sortie.createNewFile();
    OutputStreamWriter out = new OutputStreamWriter(new
    FileOutputStream(sortie), "UTF8");
    out.write("#VRML V2.0 utf8# \n # PROGRAMME test.\n # ===============\n#"
    + "\n# \nNavigationInfo {type \"EXAMINE\"}\nShape
    {\nappearance Appearance"
    + "{ material Material {}}\ngeometry PointSet {\ncoord Coordinate
    {\npoint [\n");

    for (int v = 0; v<equationsDroites.size(); v++){
    param[] t = (param[])equationsDroites.get(v);
    double[] tt = {1,1,1,1};
    double[] tp = calculPointIntersection(t, tt);

    if (tp != null)
    nbPointsInter ++;

    System.out.println("Point intersection " + nbPointsInter);
    for (int k = 0; k<tp.length; k++)
    out.write(tp[k] + " ");

    out.write("\n");
    //maChaine = maChaine + "\n";
    System.out.println("\n");


    out.write("\n]\n}}}\n\n");
    out.close();
    M, Dec 30, 2003
    #1
    1. Advertising

  2. M wrote:

    > I got a program in which i write a vrml file, i thus need it encoded into
    > utf8, but i don't know how to do it?
    > Thanks for your help.
    >
    > M.
    >
    > File sortie = new File(".../b.vrml");
    > sortie.createNewFile();
    > OutputStreamWriter out = new OutputStreamWriter(new
    > FileOutputStream(sortie), "UTF8");


    Looks like the only thing you're doing wrong is the charset name.
    It's "UTF-8", not "UTF8".
    Michael Borgwardt, Dec 30, 2003
    #2
    1. Advertising

  3. M

    M Guest

    It's not working either.
    M, Dec 30, 2003
    #3
  4. M wrote:

    > It's not working either.


    How is it not working? What's the expected and the actual result?
    Michael Borgwardt, Dec 30, 2003
    #4
  5. M

    M Guest

    I still have small squares instead of "\n" in the file
    M, Dec 30, 2003
    #5
  6. M wrote:
    > I still have small squares instead of "\n" in the file


    What is it that you *want* to appear in the file? a backslash and an 'n'
    or a newline? In the first case, you must escape the backslash with another
    backslash in your code. In the second, the problem is not with the Java code
    or the file, but with the program you're using the view the file. It's
    probably Notepad, right? To notepad, a newline character is unprintable if
    not prepended by a carriage return character.
    Michael Borgwardt, Dec 30, 2003
    #6
  7. M

    Chris Smith Guest

    M wrote:
    > I still have small squares instead of "\n" in the file
    >


    That's not likely to be related to character encoding. On Windows, the
    conventional line separator is "\r\n" rather than "\n". Some Windows
    applications, and notably Notepad, will treat a single "\n" as an
    undisplayable character, rather than a line break. That results in a
    little square.

    I am not familiar with VRML. If VRML requires \r\n as a line break,
    you'll need to write it that way. If not, perhaps the only real
    problem is that you are trying to view the VRML file with an editor that
    isn't capable of understanding what's going on.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, Dec 30, 2003
    #7
  8. M

    M Guest

    Actually, i've juste realized that my problem isn't there, when i do a cut
    and paste of a valid vrml code into an text editor, when i try to visualize
    it, it's not working, why??
    M, Dec 30, 2003
    #8
  9. M

    Roedy Green Guest

    Roedy Green, Dec 30, 2003
    #9
  10. M

    Riri Guest

    Thanks a lot the \r\n worked perfectly!
    Riri, Dec 30, 2003
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shade
    Replies:
    1
    Views:
    1,653
  2. Thomas =?ISO-8859-15?Q?G=F6tz?=

    LWP::Simple and utf8 problem

    Thomas =?ISO-8859-15?Q?G=F6tz?=, Apr 19, 2004, in forum: Perl
    Replies:
    0
    Views:
    708
    Thomas =?ISO-8859-15?Q?G=F6tz?=
    Apr 19, 2004
  3. Jeff Higgins

    convert Java unicode escape to utf8

    Jeff Higgins, Jul 6, 2007, in forum: Java
    Replies:
    12
    Views:
    11,864
    Jeff Higgins
    Jul 12, 2007
  4. gry
    Replies:
    2
    Views:
    706
    Alf P. Steinbach
    Mar 13, 2012
  5. Cameron Simpson
    Replies:
    0
    Views:
    61
    Cameron Simpson
    Mar 9, 2014
Loading...

Share This Page