C#: 中文和UNICODE字元轉換方法 及仿安居客地圖實現。。。錯誤 GMap2未定義 解決辦法 -VB 中文轉為UNICODE字元

來源:互聯網
上載者:User

錯誤 GMap2未定義 解決辦法      (關鍵在於:charset="utf-8" )

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.