经典ASP - 如何将一个UTF-8字符串UTF-16转换? [英] Classic ASP - How to convert a UTF-8 string to UTF-16?

查看:583
本文介绍了经典ASP - 如何将一个UTF-8字符串UTF-16转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有已经有帖子:<一href=\"http://stackoverflow.com/questions/916118/classic-asp-how-to-convert-a-utf-8-string-to-ucs-2\">Classic ASP - 如何将UTF-8字符串转换为UCS-2 <​​/A>

I know there is already have post: Classic ASP - How to convert a UTF-8 string to UCS-2?

但我的情况的另一个。

我想转换成UTF-8 UCS-2BE。

例如,这文本UTF-8МухтарамМизоч转换为这个CEB0 @ 0℃; 87> G。

But my situation another.
I want convert UTF-8 to UCS-2BE.
For example this text in UTF-8 "Мухтарам Мизоч" convert to this "CEB0@0<� 87>G".

例如在PHP中,我可以使用现成的功能的iconv(UTF-8,UCS-2BE,МухтарамМизоч);
但经典ASP无法找到任何解决方案。
这个解决方案需要通过发送Kannel的统一code短信。

For example in PHP i can use ready function iconv("utf-8","ucs-2be","Мухтарам Мизоч");
But in classical ASP can't find any solution.
This solution need for send Unicode SMS text via Kannel.

推荐答案

所以生病的回答这个问题,但我觉得推动为你已经取得了普遍的假设,很多化妆当谈到在ASP,PHP或任何编码语言所使用。

So sick of answering this question, but I feel impelled to as you have made a common assumption that many make when it comes to encoding in ASP, PHP or whatever language you are using.

在Web开发的编码有内在的联系。

In web development encoding is intrinsically linked to

编码用来保存网页源

只是看着让我笑,难过的iconv参考下评论在同一时间,因为有这么多的人在那里谁不明白这个话题。

Just looking at the comments under the iconv reference made me laugh and sad at the same time because there are so many people out there who don't understand this topic.

就拿你的PHP代码片段

Take for example your PHP snippet

iconv("utf-8","ucs-2be","Мухтарам Мизоч");

这将工作提供以下条件为真

This will work providing the following is true


  • 页面作者使用保存 UTF-8 编码文件(大多数现代编辑在某些形状或形式此选项)。

  • 客户端互联网浏览器知道它应该通过元标记在HTML中处理页面 UTF-8 或者

  • The page author saved the file using UTF-8 encoding (Most modern editors have this option in some shape or form).
  • The client Internet Browser knows it should be handling the page as UTF-8 either via a meta tag in the HTML,

<meta http-equiv="content-type" content="text/html; charset=utf-8">

或指定HTTP内容类型头

or by specifying a HTTP Content-Type Header

在传统的ASP方面,它是你需要的,以相同;

In terms of Classic ASP it is the same you need to;


  • 确认页面保存为 UTF-8 编码,这包括任何的#include 文件是依赖。

  • Make sure the page is saved as UTF-8 encoding, this includes any #include files that are dependencies.

告诉IIS您的网页 UTF-8 在页面的最顶端指定此pre-处理指令(必须是第一个线)。

Tell IIS that your pages are UTF-8 by specifying this pre-processing instruction at the very top of the page (must be the first line).

<%@Language="VBScript" CodePage = 65001 %>


  • 告诉你使用的是何种编码,浏览器

  • Tell the browser what encoding you are using

    <%
    'Tell server to send all strings back to the client as UTF-8
    'while also setting the charset in the HTTP Content Type header.
    Responce.CodePage = 65001
    Response.ContentType = "html/text"
    %>
    Response.Charset = "UTF-8"
    


  • 更新:

    无论是 UCS-2 <​​/ code>( UTF-16 LE)或 UCS-2BE UTF-16 BE)是由传统的ASP支持,则指定 codePAGE (1200或1201),将导致

    Neither UCS-2 (UTF-16 LE) or UCS-2BE (UTF-16 BE) are supported by Classic ASP, specifying either CodePage (1200 or 1201) will result in;

    ASP 0203 - Invalid CodePage Value

    阅读一些有关的Kannel后,它看起来好像你可以控制你发送到短信网关的字符集,我建议你尝试使用将其发送 UTF-8

    链接


    • Kannel的中发送阿拉伯SMS(这个问题是关于发送用Java的Kannel但信息阿拉伯语短信是相关的)。

    • Sending arabic SMS in kannel (This question is about sending arabic SMS using Java to Kannel but the information is relevant).

    统一code(虽然目的在Windows XP中的codePAGE信息仍然是相关的)。

    Unicode on Windows XP (Although aimed at Windows XP the codepage information is still relevant).

    这篇关于经典ASP - 如何将一个UTF-8字符串UTF-16转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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