编码转换 C#

static std::string cwstr_to_utf8(const std::wstring& in)
{
    std::string s(in.length() * 3 + 1, ' ');
    size_t len = ::WideCharToMultiByte(CP_UTF8, 0, in.c_str(), in.length(), &s[0], s.length(), NULL, NULL);
    s.resize(len);
    return s;
}

static std::wstring cutf8_to_wstr(const std::string& in)
{
    std::wstring s(in.length(), L' ');
    size_t len = ::MultiByteToWideChar(CP_UTF8, 0, in.c_str(), in.length(), &s[0], s.length());
    s.resize(len);
    return s;
}

 User user = new User();
            user.Name = "张撒";
            user.Desc = "你好";
            JsonSerializerSettings setting = new JsonSerializerSettings();
            setting.StringEscapeHandling = StringEscapeHandling.Default;
            string json = JsonConvert.SerializeObject(user, setting);
            byte[] unicodeBytes = System.Text.Encoding.UTF8.GetBytes(json);
            string jsonutf8 = Encoding.UTF8.GetString(unicodeBytes);

查看程序依赖

https://www.cnblogs.com/liweis/p/17035963.html

https://www.cnblogs.com/xcsn/p/9052360.html

List<Type> TypeItemList = new List<Type>();
            //var ResultTypeList = Assembly.GetEntryAssembly();
            //if (ResultTypeList == null)
            //{
            //    ResultTypeList = Assembly.GetCallingAssembly();
            //    var ItemList = ResultTypeList.GetReferencedAssemblies().Where(p => p.GetType() == typeof(BaseService));                
            //}
            Assembly[] AssbyCustmList = System.AppDomain.CurrentDomain.GetAssemblies();
            foreach (Assembly assItem in AssbyCustmList)
            {
                TypeItemList.AddRange(assItem.GetTypes().Where(x => x.BaseType == typeof(BaseService)).ToList());
            }
            //IEnumerable<Type> TypeItemList = CurType.Assembly.GetExportedTypes().Where(x => x.BaseType == typeof(BaseService)).ToList();
            //IEnumerable<Type> TypeItemList = ResultTypeList.GetTypes().Where(x => x.BaseType == typeof(BaseService)).ToList();
            BaseService TarService = null;
            foreach (Type typeitem in TypeItemList)
            {
                if (_Reporttory.Count(p => p.GetType() == typeitem) == 0)
                {
                    TarService = (Activator.CreateInstance(typeitem) as BaseService);
                }
                else
                {
                    TarService = _Reporttory.First(p => p.GetType() == typeitem);
                }
                TarService.Start();
            }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值