C# 繁簡中文轉換 程式碼示範

首先先使用 NuGet 安裝 ChineseConverter 套件
  
Install-Package ChineseConverter -Version 1.0.0


繁簡轉換

簡體中文轉成繁體中文

  
var output =  ChineseConverter.Convert(input, ChineseConversionDirection.SimplifiedToTraditional);


程式碼示範:
  
var input = "繁简文字转换ABCD1234";
var output =  ChineseConverter.Convert(input, ChineseConversionDirection.SimplifiedToTraditional);
Console.WriteLine(output); // 繁簡文字轉換ABCD1234


繁體中文轉成簡體中文

  
string output = ChineseConverter.Convert(input, ChineseConversionDirection.TraditionalToSimplified);


程式碼示範:
  
var input = "繁简文字转换ABCD1234";
string output = ChineseConverter.Convert(input, ChineseConversionDirection.TraditionalToSimplified);
Console.WriteLine(output); // 繁簡文字轉換ABCD1234


留言