java -utf8

M

M

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

Michael Borgwardt

M said:
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".
 
M

Michael Borgwardt

M said:
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.
 
C

Chris Smith

M said:
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
 
M

M

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??
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top