C#: 中文和UNICODE字符转换方法 及仿安居客地图实现。。。错误 GMap2未定义 解决办法 -VB 中文转为UNICODE字符
2010-04-09 11:31
1081 查看
错误 GMap2未定义 解决办法 (关键在于:charset="utf-8" )
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAnzgK6D9hdvlLyVMROdMgRxRvkvyC2uHS-ibWMJG7xp28q6sn4RSCVBqVh-Kb2lwBiDjnbXc4A9U_XQ" type="text/javascript" charset="utf-8"></script>
''/////************************* VB 中文转为UNICODE字符
''//中文转为UNICODE字符
''Dim str As String = "新景花园"
''Dim outStr As String = ""
''Dim i As Integer = 0
''For i = 1 To str.Length
'' outStr = outStr + "\u" + Hex(AscW(Mid(str, i, 1))).ToString()
''Next i
代码
context.Response.ContentType = "application/json";
context.Response.Charset = "utf-8";
string txt = "{\"50697\":[\"\u65b0\u666f\u5bb6\u56ed\",392,39.8957115,116.4256382]}";
context.Response.Write(txt);
//Response.Write("\u65b0\u666f\u5bb6\u56ed" + "<br>");
//Response.Charset = "utf-8";
//string str = "动网新闻";
//string outStr = "";
//if (!string.IsNullOrEmpty(str))
//{
// for (int i = 0; i < str.Length; i++)
// {
// //将中文字符转为10进制整数,然后转为16进制unicode字符
// outStr += "\\u" + ((int)str[i]).ToString("x");
// }
//}
//Response.Write(outStr);
//Response.End();
//////中文转为UNICODE字符
////string str = "中文";
////string outStr = "";
////if (!string.IsNullOrEmpty(str))
////{
//// for (int i = 0; i < str.Length; i++)
//// {
//// //将中文字符转为10进制整数,然后转为16进制unicode字符
//// outStr += "\\u" + ((int)str[i]).ToString("x");
//// }
////}
//////UNICODE字符转为中文
////string str = "\\u4e2d\\u6587";
////string outStr = "";
////if (!string.IsNullOrEmpty(str))
////{
//// string[] strlist = str.Replace("\\", "").Split('u');
//// try
//// {
//// for (int i = 1; i < strlist.Length; i++)
//// {
//// //将unicode字符转为10进制整数,然后转为char中文字符
//// outStr += (char)int.Parse(strlist[i], System.Globalization.NumberStyles.HexNumber);
//// }
//// }
//// catch (FormatException ex)
//// {
//// outStr = ex.Message;
//// }
////}
仿安居客地图
/Files/Fooo/haozuMap.rar
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAnzgK6D9hdvlLyVMROdMgRxRvkvyC2uHS-ibWMJG7xp28q6sn4RSCVBqVh-Kb2lwBiDjnbXc4A9U_XQ" type="text/javascript" charset="utf-8"></script>
''/////************************* VB 中文转为UNICODE字符
''//中文转为UNICODE字符
''Dim str As String = "新景花园"
''Dim outStr As String = ""
''Dim i As Integer = 0
''For i = 1 To str.Length
'' outStr = outStr + "\u" + Hex(AscW(Mid(str, i, 1))).ToString()
''Next i
代码
context.Response.ContentType = "application/json";
context.Response.Charset = "utf-8";
string txt = "{\"50697\":[\"\u65b0\u666f\u5bb6\u56ed\",392,39.8957115,116.4256382]}";
context.Response.Write(txt);
//Response.Write("\u65b0\u666f\u5bb6\u56ed" + "<br>");
//Response.Charset = "utf-8";
//string str = "动网新闻";
//string outStr = "";
//if (!string.IsNullOrEmpty(str))
//{
// for (int i = 0; i < str.Length; i++)
// {
// //将中文字符转为10进制整数,然后转为16进制unicode字符
// outStr += "\\u" + ((int)str[i]).ToString("x");
// }
//}
//Response.Write(outStr);
//Response.End();
//////中文转为UNICODE字符
////string str = "中文";
////string outStr = "";
////if (!string.IsNullOrEmpty(str))
////{
//// for (int i = 0; i < str.Length; i++)
//// {
//// //将中文字符转为10进制整数,然后转为16进制unicode字符
//// outStr += "\\u" + ((int)str[i]).ToString("x");
//// }
////}
//////UNICODE字符转为中文
////string str = "\\u4e2d\\u6587";
////string outStr = "";
////if (!string.IsNullOrEmpty(str))
////{
//// string[] strlist = str.Replace("\\", "").Split('u');
//// try
//// {
//// for (int i = 1; i < strlist.Length; i++)
//// {
//// //将unicode字符转为10进制整数,然后转为char中文字符
//// outStr += (char)int.Parse(strlist[i], System.Globalization.NumberStyles.HexNumber);
//// }
//// }
//// catch (FormatException ex)
//// {
//// outStr = ex.Message;
//// }
////}
仿安居客地图
/Files/Fooo/haozuMap.rar
相关文章推荐
- C#中文和UNICODE字符转换方法
- C#中文和UNICODE字符转换方法
- ReadString在UNICODE下中文乱码的解决办法(Char型字符和Unicode字符的转换问题)
- ReadString在UNICODE下中文乱码的解决办法(Char型字符和Unicode字符的转换问题)
- C#中文和UNICODE字符转换方法
- C#中文和UNICODE字符转换方法
- androidStudio 中文编译错误: GBK 的不可映射字符。(针对网上通用资料无法解决办法)
- C#实现VB中的asc和chr函数,字符(含中文)转ASCII
- 通过findViewById()方法从layout中获取view并进行相应的转换时提示:"Cannot cast from View to AutoCompleteTextView"的解决办法!(转+自己错误)
- .Net/C#/VB/T-SQL/Java 实现: 将天文数字转换成中文大写 (2000 年前的思路,打劫的,一点儿技术含量都没有)
- C#中关于从剪贴板中读取HTML格式含中文字符会出现的问题和解决方法
- 通过httpwebrequest实现http的post和get方法莫名出现500内部服务器错误的解决办法
- C# 读取含中文字符的数据,失败原因,和解决办法
- unicode和多字节字符中CString转string方法,可解决中文乱码的问题
- 使用C#实现阿拉伯数字到大写中文的转换-第二种方法
- SpringBoot集成Swagger2实现Restful(类型转换错误解决办法)
- SpringBoot集成Swagger2实现Restful(类型转换错误解决办法)
- C#从剪贴板获取HTML格式内容含中文字符出现的问题和解决方法
- Scrapy爬虫框架抓取中文结果为Unicode编码,如何转换UTF-8编码的解决办法
- C#网络通信中中文字符的传送以及SQL数据库存取中文的解决方法