如何将从条形码读取的文本转换为阿拉伯文本 [英] how to convert text readed from barcode to arabic text

查看:43
本文介绍了如何将从条形码读取的文本转换为阿拉伯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类型为pdf417"的条形码图像,它包含一个阿拉伯文本,当使用条形码读取它时,它会通过这样的文本ㄧㄧㄋ"如何将此文本转换为其原始文本(阿拉伯语)

I have barcode image with type "pdf417",it content a arabic text , When read it using barcode it through a text like this "ÃÍãÏ#" how can I convert this text to its original text (arabic)

推荐答案

如果你的方法给你一个 byte[] 使用:

If your method gives you a byte[] use:

var str = Encoding.UTF8.GetString(yourBytes);

或者,也许

var str = Encoding.GetEncoding(1256) // 1256 is the Windows Arabic codepage
                  .GetString(yourBytes);

如果你的方法给你一个 string 这样做:

If your method gives you a string do this:

// iso-8859-1 is a codepage that can be used to convert back some 
// malformed unicode strings
var str = Encoding.GetEncoding(1256)
                  .GetString(Encoding.GetEncoding("iso-8859-1")
                                     .GetBytes(yourString));

您一开始问题中的文字已被转换为:

The text you had in your question in the beginning was converted with this to:

أحمد#المنير#محمد#فاطمه #حرستا 27-12-1949#

请注意,只有 UTF8 格式才能使条形码通用"(因为 UTF8 可以表示所有 Unicode 字符).1256 代码页将使您的条形码具有区域性"(您必须知道您的条形码写在哪里才能想象它可以使用 1256 Windows 阿拉伯语代码页进行编码)

Note that only the UTF8 format will make the barcode "universal" (because UTF8 can represent all the Unicode characters). The 1256 codepage will make your barcode "regional" (you have to know where your barcode was written to imagine it could be encoded with the 1256 Windows Arabic codepage)

这篇关于如何将从条形码读取的文本转换为阿拉伯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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