Java帮助中的UNICODE [英] UNICODE in Java Help

查看:42
本文介绍了Java帮助中的UNICODE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。


我正在尝试从

游戏中为几何文件编写Java3D加载程序,该游戏具有Unicode字符(韩文)它。我写了装载机

,它可以在Windows中运行,但我最近完全放弃了Windows,而且现在已经在Linux下了。当我现在尝试加载文件名时,我得到??????。

这是我的加载器中的代码块,它从<<读取字符串

br $>
文件:


/ **获取纹理文件的数量* /

numTextures = in.readInt();


/ **向前跳过4个字节* /

in.skipBytes(4);


/ **加载纹理文件字符串* /

textures = new String [numTextures];

for(int i = 0; i< numTextures; i ++){

/ **读取40字节缓冲区* /

in.read(bmpPath);


/ **修剪缓冲区到长度和存储* /

for(len = 0; len< 40; len ++){

if(bmpPath [len] == 0)

休息;

}

textures [i] = new String(bmpPath,0,len);


/ ** skip提前40个字节* /

in.skipBytes(40);

}


当它进入String数组时它一切都搞砸了,并没有正确代表正确的
路径了。

当前读取器占用40个字节,然后计算出

字符串的长度。文件中没有字符串长度指示,

所以我必须在字节数组中弄明白。


有没有人对我如何有任何建议解决这个问题所以我可以在Windows和Linux(以及其他操作系统)中阅读

韩文文本?


感谢您的帮助!

Hello all.

I am trying to write a Java3D loader for a geometry file from a
game, which has Unicode characters (Korean) in it. I wrote the loader
and it works in Windows, but I recently brushed off Windows completely
and am now under Linux. When I try to load the filenames now, I get ??????.
This is the block of code in my loader which reads the strings
from the
file:

/** get the number of texture files */
numTextures = in.readInt();

/** skip ahead 4 bytes */
in.skipBytes(4);

/** load the texture files strings */
textures = new String[numTextures];
for (int i=0; i < numTextures; i++) {
/** read in the 40 byte buffer */
in.read(bmpPath);

/** trim buffer to length and store */
for (len=0; len < 40; len++) {
if (bmpPath[len] == 0)
break;
}
textures[i] = new String(bmpPath, 0, len);

/** skip ahead 40 bytes */
in.skipBytes(40);
}

By the time it enters the String array it is all messed up and does not
properly represent the correct paths anymore.
The current reader takes in 40 bytes and then figures out how long the
string is from there. There is no string length indication in the file,
so I have to figure it out within the byte array.

Does anyone have any suggestions on how I fix this so I can read the
Korean text in both Windows and Linux (and other OSs)?

Thank you for any help!

推荐答案

2004年5月27日星期四03:54:01 GMT,Nicholas Pappas

< no ***** @ rightstep .ORG>编写或引用:
On Thu, 27 May 2004 03:54:01 GMT, Nicholas Pappas
<no*****@rightstep.org> wrote or quoted :
numTextures = in.readInt();
numTextures = in.readInt();




关键是in的声明。什么格式这些数据是?什么

编码?


http://mindprod.com/fileio.html

选择正确的方法。


-

Canadian Mind Products,Roedy Green。

辅导,解决问题,经济合同编程。

参见 http://mindprod.com/jgloss/jgloss.html 的Java词汇表。



The key is the declaration of in. What format are these data? What
encoding?

See http://mindprod.com/fileio.html
to select the correct method.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


Roedy Green写道:
Roedy Green wrote:
2004年5月27日星期四03:54:01 GMT,Nicholas Pappas
On Thu, 27 May 2004 03:54:01 GMT, Nicholas Pappas
numTextures = in.readInt();
numTextures = in.readInt();



关键是in的声明。这些数据的格式是什么?什么
编码?



The key is the declaration of in. What format are these data? What
encoding?




''''是一个LittleEndianInputStream,它扩展了FilterInputStream和

实现了DataInput。在读取字节的情况下(就像

构造有问题的字符串一样),read()函数很简单。

传递 - 没有更改默认行为。

我收到了关于编码的另一个建议,今晚我回家的时候会尝试
。但是,我担心我会为Linux工作(可能选择UTF-8)然后

它将停止在Windows中工作。

会在Linux下强制输入流到某个特定的编码

Windows?



''in'' is a LittleEndianInputStream, which extends FilterInputStream and
implements DataInput. In the case of reading bytes (as done to
construct the Strings in question), the read() function is simple a
pass-through -- no changes to the default behavior.
I received another suggestion about the encoding and will be trying
that this evening when I get home. However, I''m concerned that I am
going to get this working for Linux (perhaps by select UTF-8) and then
it will stop working in Windows.
Will forcing the input stream to a certain encoding under Linux break
Windows?


在Java下你是假设的要屏蔽机器级别的详细信息和

包括unicode问题....是jt与Windows平台上使用的

相同或更晚... ?


- perry


Nicholas Pappas写道:
under Java you are suppose to be shielded from machine level details and
that includes unicode issues.... is the jre the same or later than the
one used on your windows platform...?

- perry

Nicholas Pappas wrote:
大家好。

我正在尝试从
游戏中为几何文件编写Java3D加载器,其中包含Unicode字符(韩文)。我编写了加载器
并且它可以在Windows中运行,但我最近完全放弃了Windows,现在我已经在Linux下了。当我现在尝试加载文件名时,我得到了
??????。
这是我的加载器中的代码块,它从
文件中读取字符串


/ **获取纹理文件的数量* /
numTextures = in.readInt();

/ **向前跳过4个字节* /
in.skipBytes(4);

/ **加载纹理文件字符串* /
textures = new String [numTextures];
for(int i = 0 ; i< numTextures; i ++){
/ **在40字节缓冲区中读取* /
in.read(bmpPath);

/ **修剪缓冲区到长度并存储* /
(len = 0; len< 40; len ++){
if(bmpPath [len] == 0)
break;
}
textures [i] = new String(bmpPath,0,len);

/ **跳过40字节* /
in.skipBytes(40);
}

当它进入String数组时,它全部搞砸了并且没有正确表示正确的路径再过来。
当前读者需要40个字节,然后计算出字符串的长度。
文件中没有字符串长度指示,所以我必须在字节数组中弄明白。

有没有人对我如何解决这个问题有任何建议,所以我可以阅读< Windows和Linux(以及其他操作系统)中的韩文文本?

感谢您的帮助!
Hello all.

I am trying to write a Java3D loader for a geometry file from a
game, which has Unicode characters (Korean) in it. I wrote the loader
and it works in Windows, but I recently brushed off Windows completely
and am now under Linux. When I try to load the filenames now, I get
??????.
This is the block of code in my loader which reads the strings
from the
file:

/** get the number of texture files */
numTextures = in.readInt();

/** skip ahead 4 bytes */
in.skipBytes(4);

/** load the texture files strings */
textures = new String[numTextures];
for (int i=0; i < numTextures; i++) {
/** read in the 40 byte buffer */
in.read(bmpPath);

/** trim buffer to length and store */
for (len=0; len < 40; len++) {
if (bmpPath[len] == 0)
break;
}
textures[i] = new String(bmpPath, 0, len);

/** skip ahead 40 bytes */
in.skipBytes(40);
}

By the time it enters the String array it is all messed up and does
not properly represent the correct paths anymore.
The current reader takes in 40 bytes and then figures out how long
the string is from there. There is no string length indication in the
file, so I have to figure it out within the byte array.

Does anyone have any suggestions on how I fix this so I can read the
Korean text in both Windows and Linux (and other OSs)?

Thank you for any help!






这篇关于Java帮助中的UNICODE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆