How to write Unicode and International Languages Barcodes in C#

This article was translated from English: Does it need improvement?
Translated
View the article in English

When writing international languages barcodes, there are a few factors that developers must consider, such as the length of the string and the barcode writing encoding that is appropriate for the string value, as well as the general purpose of the output barcode. IronBarcode fully supports generating and writing barcodes in Unicode, allowing developers to cross borders and have their products placed internationally with barcodes with ease. The following how-to guide provides code examples and considerations that developers must consider when generating them.

Quickstart: Create a Unicode Barcode with DataMatrix Encoding

This quick example shows how developers can instantly generate a barcode containing mixed-language Unicode text using IronBarcode in just one line, then save it as an image—get started effortlessly.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronBarcode with NuGet Package Manager

    PM > Install-Package BarCode

  2. Copy and run this code snippet.

    var barcode = IronBarCode.BarcodeWriter.CreateBarcode("123 英語 اللغة العربية", IronBarCode.BarcodeWriterEncoding.DataMatrix);
    barcode.SaveAsImage("unicode.png");
  3. Deploy to test on your live environment

    Start using IronBarcode in your project today with a free trial
    arrow pointer

Writing Unicode Barcode Example

Thanks to IronBarcode's robust support for writing and generating barcodes in Unicode, developers can confidently add and create strings that contain multiple languages to use as a value. For instance, a string that includes a mix of Chinese, Arabic, and Thai can be easily handled, showcasing the tool's versatility and empowering developers to work with diverse language sets.

Below is the following string that we'll use as a barcode value.

string unicodeText = "周態告応立待太記行神正用真最。音日独素円政進任見引際初携食。更火識将回興継時億断保媛全職。文造画念響竹都務済約記求生街東。天体無適立年保輪動元念足総地作靖権瀬内。失文意芸野画美暮実刊切心。感変動技実視高療試意写表重車棟性作家薄井。陸瓶右覧撃稿法真勤振局夘決。任堀記文市物第前兜純響限。囲石整成先尾未展退幹販山令手北結。أم يذكر النفط قبضتهم على, الصين وفنلندا ما حدى. تم لكل أملا المنتصر, ٣٠ حدى مارد القوى. شرسة للسيطرة قامفي. حتى أم يطول المحيط, زهاء وحلفاؤها من فعل. لم قامت الجو الساحلية وتم, ويعزى واقتصار قبل كل。ภคนทลาพาธสตารเซฟต แชมป มารเกตตงลมเหลวโยเกรต แลนดบาบนอมครม รสโซ แบรนดไคลแมกซ พซซาโมเดลเสอโครง มอบโซนรายชอ แอดมชชน ดอกเตอร พะเรอ มารคเจไดโมจราสเบอรร เอนทรานซออดชนศลปวฒนธรรมเปราะบาง โมจซเรยสวอลนตทรป";
string unicodeText = "周態告応立待太記行神正用真最。音日独素円政進任見引際初携食。更火識将回興継時億断保媛全職。文造画念響竹都務済約記求生街東。天体無適立年保輪動元念足総地作靖権瀬内。失文意芸野画美暮実刊切心。感変動技実視高療試意写表重車棟性作家薄井。陸瓶右覧撃稿法真勤振局夘決。任堀記文市物第前兜純響限。囲石整成先尾未展退幹販山令手北結。أم يذكر النفط قبضتهم على, الصين وفنلندا ما حدى. تم لكل أملا المنتصر, ٣٠ حدى مارد القوى. شرسة للسيطرة قامفي. حتى أم يطول المحيط, زهاء وحلفاؤها من فعل. لم قامت الجو الساحلية وتم, ويعزى واقتصار قبل كل。ภคนทลาพาธสตารเซฟต แชมป มารเกตตงลมเหลวโยเกรต แลนดบาบนอมครม รสโซ แบรนดไคลแมกซ พซซาโมเดลเสอโครง มอบโซนรายชอ แอดมชชน ดอกเตอร พะเรอ มารคเจไดโมจราสเบอรร เอนทรานซออดชนศลปวฒนธรรมเปราะบาง โมจซเรยสวอลนตทรป";
Dim unicodeText As String = "周態告応立待太記行神正用真最。音日独素円政進任見引際初携食。更火識将回興継時億断保媛全職。文造画念響竹都務済約記求生街東。天体無適立年保輪動元念足総地作靖権瀬内。失文意芸野画美暮実刊切心。感変動技実視高療試意写表重車棟性作家薄井。陸瓶右覧撃稿法真勤振局夘決。任堀記文市物第前兜純響限。囲石整成先尾未展退幹販山令手北結。أم يذكر النفط قبضتهم على, الصين وفنلندا ما حدى. تم لكل أملا المنتصر, ٣٠ حدى مارد القوى. شرسة للسيطرة قامفي. حتى أم يطول المحيط, زهاء وحلفاؤها من فعل. لم قامت الجو الساحلية وتم, ويعزى واقتصار قبل كل。ภคนทลาพาธสตารเซฟต แชมป มารเกตตงลมเหลวโยเกรต แลนดบาบนอมครม รสโซ แบรนดไคลแมกซ พซซาโมเดลเสอโครง มอบโซนรายชอ แอดมชชน ดอกเตอร พะเรอ มารคเจไดโมจราสเบอรร เอนทรานซออดชนศลปวฒนธรรมเปราะบาง โมจซเรยสวอลนตทรป"
$vbLabelText   $csharpLabel

We then call the BarcodeWriter.CreateBarcode method to create the desired barcode. The method takes in two values: the text and the encoding.

:path=/static-assets/barcode/content-code-examples/how-to/writing-in-unicode-write.cs
using IronBarCode;

// Unicode text with Chinese, Arabic and Thai characters
string text = "周態告応立待太記行神正用真最。音日独素円政進任見引際初携食。更火識将回興継時億断保媛全職。文造画念響竹都務済約記求生街東。天体無適立年保輪動元念足総地作靖権瀬内。失文意芸野画美暮実刊切心。感変動技実視高療試意写表重車棟性作家薄井。陸瓶右覧撃稿法真勤振局夘決。任堀記文市物第前兜純響限。囲石整成先尾未展退幹販山令手北結。أم يذكر النفط قبضتهم على, الصين وفنلندا ما حدى. تم لكل أملاً المنتصر, ٣٠ حدى مارد القوى. شرسة للسيطرة قامفي. حتى أم يطول المحيط, زهاء وحلفاؤها من فعل. لم قامت الجو الساحلية وتم, ويعزى واقتصار قبل كل。ภคันทลาพาธสตาร์เซฟตี้ แชมป์ มาร์เก็ตติ้งล้มเหลวโยเกิร์ต แลนด์บาบูนอึมครึม รุสโซ แบรนด์ไคลแม็กซ์ พิซซ่าโมเดลเสือโคร่ง ม็อบโซนรายชื่อ แอดมิชชั่น ด็อกเตอร์ พะเรอ มาร์คเจไดโมจิราสเบอร์รี เอนทรานซ์ออดิชั่นศิลปวัฒนธรรมเปราะบาง โมจิซีเรียสวอลนัตทริป";

// Create a DataMatrix barcode with the specified text
var myBarcode = BarcodeWriter.CreateBarcode(text, BarcodeWriterEncoding.DataMatrix);

// Save the barcode as an image
myBarcode.SaveAsImage("Unicode.jpeg");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

This is the file that the code produced:

Output Unicode Barcode

Unicode Barcode Writing Encoding

Due to how Unicode works, only selected Barcode types natively support them and directly store Unicode text without encoding workarounds. Aside from the DataMatrix encoding we've done above, here's a quick list of encoding types that support Unicode.

Barcode Type Unicode Support Best For Max Capacity
QR Code Full UTF-8 (Kanji mode for CJK) Marketing, multilingual labels, IDs ~3,000 chars (alphanumeric)
Data Matrix With ECI (Extended Channel Interpretation) Industrial, small item labels ~1,556 bytes
PDF417 With ECI (but limited scanner support) Documents (boarding passes, IDs) ~1,100 bytes
Aztec Code Native UTF-8 Mobile tickets, airline passes ~3,000 chars

Note the difference in the number of characters you can fit with each barcode encoding type. For example, using the string above with PDF417 won't work, as it contains more than 500 Unicode characters. In this case, you need to implement a workaround to make it work. As such, it's important to note the length of your string.

The Barcode types listed above are all available from BarcodeWriterEncoding.

For a complete list of all available barcode encoding types from BarcodeWriterEncoding, please refer here.

Reading the Unicode Barcode

Aside from writing in Unicode, IronBarcode also supports reading Unicode barcodes. To read the barcode, we use the Read method from the BarcodeReader class with the provided parameter being the Unicode barcode.

Here's a quick example using the Unicode barcode generated from above:

:path=/static-assets/barcode/content-code-examples/how-to/writing-in-unicode-read.cs
using IronBarCode;
using System.IO;

// Reading the Unicode barcode
BarcodeResults result = BarcodeReader.Read("Unicode.jpeg");

// Output the text value from the barcode to a txt file
File.WriteAllText("text.txt", result[0].Text);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Note that although you can output the text value to a terminal with Console.WriteLine, the terminal doesn't natively support displaying Unicode characters and requires additional setup. In this example, we directed the output to a txt file instead.

Output

alt text

常见问题解答

为什么我需要生成Unicode条形码?

生成Unicode条形码对于支持包括中文、阿拉伯文等在内的国际语言至关重要,使企业可以跨不同地区运营并与多元化受众有效沟通。

IronBarcode可以处理Unicode字符吗?

是的,IronBarcode支持生成带有Unicode字符的条形码,使得可以对包括中文和阿拉伯文在内的多种国际语言进行文本编码。

使用IronBarcode可以创建哪些类型的带Unicode字符的条形码?

使用IronBarcode,您可以创建各种类型的条形码,例如QR码和Code 128,使用Unicode字符。这种灵活性非常适合需要国际化的应用程序。

是否可以自定义IronBarcode中Unicode条形码的外观?

是的,IronBarcode允许您自定义Unicode条形码的外观,包括大小、颜色和字体,以确保条形码符合您的设计和品牌要求。

我需要特殊软件来读取用IronBarcode创建的Unicode条形码吗?

不需要特殊软件来读取用IronBarcode创建的Unicode条形码。能够读取特定条形码格式的标准条形码扫描仪和软件可以进行解读。

我可以生成包含Unicode和ASCII字符组合的条形码吗?

是的,IronBarcode支持生成包含Unicode和ASCII字符组合的条形码,提供了在编码各种数据时的灵活性。

IronBarcode如何处理诸如阿拉伯语等RTL(从右到左)语言?

IronBarcode能够处理诸如阿拉伯语等从右到左的语言,通过在生成的条形码中正确编码文本方向,确保准确表示和可读性。

使用IronBarcode生成Unicode条形码有哪些优势?

IronBarcode操作简单,对各种条形码格式的兼容性,以及对国际语言的支持和自定义选项,使其成为生成Unicode条形码的理想选择。

使用IronBarcode编码Unicode条形码的字符数量是否有限制?

使用IronBarcode编码Unicode条形码的字符数量取决于条形码类型和大小。然而,IronBarcode被设计为可以有效处理大量数据。

IronBarcode可以生成适用于桌面和移动应用程序的条形码吗?

是的,IronBarcode可以生成适用于桌面和移动应用程序的条形码,为不同平台和设备提供多样性。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 1,935,276 | 版本: 2025.11 刚刚发布