本文介绍了C# Web 服务中的西里尔字母编码不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
从网络服务解析 UTF8 编码数据

我编写了小型网络服务,用于将数据插入数据库.

I've written small web service which inserts data to the DB.

它需要参数comment":

It takes parameter "comment":

CreateBuy(DateTime date, String cardNumber, Decimal amount, String comment)
{
    ...
}

它适用于拉丁字母,但是当我尝试传递 comment = "Продукт1" 的值时,它会传递给存储过程值 @comment = '?YN€????N???N‚1''Продукт1'.

It works fine with latin letters, but when I try to pass value of comment = "Продукт1" it passes to the stored procedure value @comment = '?YN€????N???N‚1' instead of 'Продукт1'.

如何解决?

推荐答案

为此字符串使用本地化参数.为避免此类问题,同时使用英语和俄语最好使用 Utf-8 编码.

Use localization parameters for this string. To avoid such problems, working both with english and russian better use Utf-8 encoding.

这篇关于C# Web 服务中的西里尔字母编码不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 17:54
查看更多