C#+ASCII 与 JS+ASCII 

C# 复制代码C#+ASCII ,转自MSDN
using System;
using System.Text;

namespace Encoding_Examples
{
    using System;
    using System.Text;

    class EncodingExample
    {
        public static void Main()
        {
            // Create an ASCII encoding.
            Encoding ascii = Encoding.ASCII;
       
            // A Unicode string with two characters outside the ASCII code range.
            String unicodeString =
                "This unicode string contains two characters " +
                "with codes outside the ASCII code range, " +
                "Pi (/u03a0) and Sigma (/u03a3).";
            Console.WriteLine("Original string:");
            Console.WriteLine(unicodeString);

            // Save the positions of the special characters for later reference.
            int indexOfPi = unicodeString.IndexOf('/u03a0');
            int indexOfSigma = unicodeString.IndexOf('/u03a3');

            // Encode the string.
            Byte[] encodedBytes = ascii.GetBytes(unicodeString);
            Console.WriteLine();
            Console.WriteLine("Encoded bytes:");
            foreach (Byte b in encodedBytes)
            {
                Console.Write("[{0}]", b);
            }
            Console.WriteLine();
       
            // Notice that the special characters have been replaced with
            // the value 63, which is the ASCII character code for '?'.
            Console.WriteLine();
            Console.WriteLine(
                "Value at position of Pi character: {0}",
                encodedBytes[indexOfPi]
                );
            Console.WriteLine(
                "Value at position of Sigma character: {0}",
                encodedBytes[indexOfSigma]
                );

            // Decode bytes back to a string.
            // Notice missing the Pi and Sigma characters.
            String decodedString = ascii.GetString(encodedBytes);
            Console.WriteLine();
            Console.WriteLine("Decoded bytes:");
            Console.WriteLine(decodedString);
        }
    }
}
 JS+ASCII

<html >
<head >
<script type="text/javascript" >
var str = "31243,32455,26381";
var v = str.split( ', ');
for(i=0;i <v.length;i++){
    document.write(String.fromCharCode(v[i]));
}
</script >
</head >
<body >
……………………

----------------

<script language="javascript" type="text/javascript">
for(var i= 19968;i<=40869;i++)
 document.write("&#" + i+" ");
</script>
汉字ASCII编码范围为19968-40869

这是为一个帖子的回复总结

http://topic.csdn.net/u/20071002/13/d34c6478-f48c-4236-9579-5e07ccaaff76.html?seed=1064251217

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值