转换 unicode 字符 (C#) 测试 [英] Converting unicode characters (C#) Testing

查看:59
本文介绍了转换 unicode 字符 (C#) 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题

我正在使用从数据库返回值的 SDK.

I am using an SDK that returns values form a database.

我需要的值是 4, 6, 7 但 SDK 返回 "\u0004","\u0006","\u0007" 我想知道是否有办法检查它是否是 "\u0004","\u0006"、"\u0007" 或其他任何方式?

The value i need is 4, 6, 7 but the SDK returns "\u0004","\u0006","\u0007" I was wondering if there is a way to check if it is "\u0004","\u0006","\u0007" or any way of doing this?

我有以下代码(C#):

I Have the following code (C#):

Line_Type = Line_Type.Replace(@"\u000", "");
if (Line_Type == "4")
{
    Line_Type = "4";
}
else if (Line_Type == "6")
{
    Line_Type = "6";
}
else if (Line_Type == "7")
{
    Line_Type = "7";
}

我尝试了多种方法来完成这项工作,但找不到正确的方法来完成这项工作.

I have tried multiple ways to get the done but can't find a right way to get this done.

我有谷歌但找不到任何东西.

I Have google but can't find anything.

推荐答案

从你的问题我了解到 SDK 以 unicode 样式返回值.然后您可以使用以下代码将 unicode 值转换为相应的十进制值.

From your question I understood that SDK returns values in unicoded style. Then you can use the following code to convert unicode values to respective decimal value.

char uniCodeValue = char.Parse(Line_Type);//  '\u0004' unicode values
int decimalValue = uniCodeValue;
Console.Write(decimalValue.ToString()); // prints 4

希望你的问题得到解决!!

Hope your problem got solved!!

这篇关于转换 unicode 字符 (C#) 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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