读取Dicom文件中的汉字
我刚刚开始了解 Dicom 标准。我正在尝试编写一个小程序,它将读取 dicom 文件并将信息转储到文本文件中。我有一个包含中文患者姓名的数据集。我如何读取和存储这些名称?
目前,我正在从 dicom
文件中读取 Char*
名称,将此 char*
转换为 wchar*
使用中文代码页“950”并写入文本文件。我在文本文件中看到的是 *
?
和 %
,而不是中文字符。我缺少什么?
我在 Windows 上使用 C++ 工作。
I have just started to get a feel of Dicom standard. I am trying to write a small program, that would read a dicom
file and dump the information to a text file. I have a dataset that has the patient names in Chinese. How can I read and store these names?
Currently, I am reading the names as Char*
from the dicom
file, converting this char*
to wchar*
using code page "950" for Chinese and writing to a text file. Instead of seeing Chinese characters I see *
?
and %
in my text file. What am I missing?
I am working in C++ on Windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果文本文件包含 UTF-16,是否包含 BOM?
If the text file contains UTF-16, have you included a BOM?
手头可能有多个问题。
首先,你知道中文名字的字符编码吗,比如Big5还是GB*?参见http://en.wikipedia.org/wiki/Chinese_character_encoding
二、你知道编码吗你的输出文本文件?如果是ascii,那么你可能永远无法查看汉字。在这种情况下,我建议将其更改为unicode(即UTF-8)。
然后,当您读取中文名称时,将原始字节转换并写出结果。例如,如果 DICOM 将其存储在 Big5 中,并且您的文本文件是 UTF-8,则您将需要 Big5->UTF-8 转换器。
There may be multiple issues at hand.
First, do you know the character encoding of the Chinese name, e.g. Big5 or GB*? See http://en.wikipedia.org/wiki/Chinese_character_encoding
Second, do you know the encoding of your output text file? If it is ascii, then you probably won't ever be able to view the Chinese characters. In which case, I would suggest changing it to unicode (i.e. UTF-8).
Then, when you read the Chinese name, convert the raw bytes and write out the result. For example, if the DICOM stores it in Big5, and your text file is UTF-8, you will need a Big5->UTF-8 converter.