注意此函数支持是\u格式如果是%u可以先替换成\u,这个函数可以在usc2中插入不相关的解码字符,比如:你好\u1234不会影响解码,这个就是用寻找字符方法实现的,其实也可以用正则表达式方法搞定,这里足够用了。 public static String decodeUnicode(String data) {
方法名 ucs2解码 返回值 文本型 参数名 ucs2 类型 文本型 然后写代码 @ final StringBuffer buffer = new StringBuffer(); @ (findIndex>-1) @ { @ if(findIndex==offsetIndex) @ { @ charStr=@<ucs2 findIndex+6; @ buffer.append(result); @ }else @ { @ result=@<ucs2 >.length()-1) @ { @ buffer.append(@<ucs2>.substring(offsetIndex)); @ } @ @ @<ucs2>=buffer.toString(); 返回(ucs2)
在Office文件的ZIP压缩包里,解压之后,customUI.xml的编码是UTF-8,VBA中的编码是UCS2(Unicode的学名是"Universal Multiple-Octet Coded Character Set",简称为UCS,VBA中使用的UCS2就是用两个字节编码)。 关于编码方法的知识,建议网上找找资料看看,UTF-8与UCS2之间是有规律的,完全可以根据位移来实现编码的转换。 As Byte = 15 Private Const b_0011_1100 As Byte = 60 Private Const b_0000_0010 As Byte = 2 01 UTF-8转UCS2 ilensrc As Long ilensrc = UBound(SrcUCS2) + 1 If ilensrc < 2 Then ToUTF8 = "输入的<em>UCS2</em>
| 90 | | Yes | 1 | PAD SPACE | | ucs2_croatian_ci | ucs2 | 149 | | Yes | 8 | PAD SPACE | | ucs2_czech_ci | ucs2 | 138 | SPACE | | ucs2_general_mysql500_ci | ucs2 | 159 | | Yes | 1 | PAD SPACE | ucs2 | 140 | | Yes | 8 | PAD SPACE | | ucs2_persian_ci | ucs2 | ucs2 | 128 | | Yes | 8 | PAD SPACE | | ucs2_vietnamese_ci | ucs2
35 Yes Yes 1 ucs2_bin ucs2 90 Yes 1 ucs2_unicode_ci ucs2 128 Yes 8 ucs2_icelandic_ci ucs2 129 Yes 8 ucs2_latvian_ci ucs2 ucs2 136 Yes 8 ucs2_turkish_ci ucs2 137 Yes 8 ucs2_czech_ci ucs2 138 Yes 8 ucs2_danish_ci ucs2 139 Yes 8 ucs2_lithuanian_ci ucs2 140 Yes 8 ucs2_slovak_ci ucs2 141 Yes 8 ucs2_spanish2
而二进制的数据转为字符串的时候就需要指定字符集,Buffer 的 from、byteLength、lastIndexOf 等方法都支持指定 encoding: 具体支持的 encoding 有这些: utf8、ucs2 , val, byteOffset, dir) => indexOfString(buf, val, byteOffset, encodingsMap.utf8, dir) }, ucs2 : { encoding: 'ucs2', encodingVal: encodingsMap.utf16le, byteLength: (string) => string.length encoding.length) { case 4: if (encoding === 'utf8') return encodingOps.utf8; if (encoding === 'ucs2 Node.js 通过 Buffer 存储二进制数据,而转为字符串时需要指定编码方案,这个编码方案不只是包含字符集(charset),也支持 hex、base64 的方案,包括: utf8、ucs2、utf16le
mysql> select hex(convert('é' using ucs2)),hex(convert('池' using ucs2)); +--------------------------- ----+--------------------------------+ | hex(convert('é' using ucs2)) | hex(convert('池' using ucs2)) +-------------------------------+--------------------------------+ 1 row in set (0.00 sec) UCS2 也可以从 Unicode 代码点反查字符: mysql> select convert(unhex('00E9') using ucs2), convert(unhex('6C60') using ucs2 ) | convert(unhex('6C60') using ucs2) | +-----------------------------------+------------------------
字符集latin1的快捷方式ASCII和UNICODE的快捷方式ucs2被弃用,MySQL的未来版本中将删除它们。用户可以使用CHARACTER SET代替。 字符集及排序规则ucs2、macroman、macce、dec、p8将降级,未来将删除。用户可以使用utf8mb4代替。
vim在linux下默认是以utf-8来编码文件和解析文件的,当使用vim来打开ucs2编码的文件时,会出现乱码,此时使用set fileencoding显示的是utf-8编码,而不是ucs2编码,读者可自行验证 命令如下: vim file_name -c "e ++enc=ucs2" 或者在使用vim打开文件之后,在末行模式使用如下命令: :e ++enc=ucs2 #或者,不改变文件编码类型 :set encoding =ucs2 注意: 如果终端,比如SecureCRT或者XSell不支持ucs2编码的话,那么还是会出现乱码,尽管vim已经采用正确的编码格式解析了ucs2的文件。
主要需要实现的功能: ZIP文件的读、写 xml文本的解析 UCS2和UTF-8编码之间的转换 使用xsd验证xml(这个目前没能实现)
这包括往返于UTF-8,UCS2,Base64,ASCII,UTF-16甚至HEX编码方案。 您甚至可以使用它执行ASCII,HEX,UTF-16和UCS2编码和解码。 如果您想了解有关JavaScript中Base64转换的更多信息,请参阅本指南。 喜欢这篇文章吗?
包含默认 cypress.json 配置文件的目录)中需要读取的文件的路径 encoding 读取时需要使用的编码 ascii base64 binary hex latin1 utf8 utf-8 ucs2
HS_FDS_SUPPORT_STATISTICS= FALSE HS_LANGUAGE=AMERICAN_AMERICA.AL32UTF8 --oracle数据库字符集 HS_NLS_NCHAR=UCS2 HS_FDS_SUPPORT_STATISTICS= FALSE HS_LANGUAGE=AMERICAN_AMERICA.AL32UTF8 --oracle数据库字符集 HS_NLS_NCHAR=UCS2
Else Exit Sub End If Else '将读取到customUI.xml Byte数组,编码UTF8转换为UCS2
Unicode属于例外情况; 可使用utf8 字符集 , 而非ucs2字符集。 诸如汉语和日语这样的表意语言没有自定界符。
Buffer 与字符编码 Buffer 实例一般用于表示编码字符的序列,比如 UTF-8 、 UCS2 、 Base64 、或十六进制编码的数据。 ucs2 - utf16le 的别名。 base64 - Base64 编码。 latin1 - 一种把 Buffer 编码成一字节编码的字符串的方式。 binary - latin1 的别名。
filePath 文件路径,默认会从 cypress/fixtures 文件夹下找文件 encoding 读取文件时使用的编码 ascii base64 binary hex latin1 utf8 utf-8 ucs2
中需要写入的文件的路径 contents 要写入文件的内容,可以是字符串、数组、对象类型 encoding 写入时需要使用的编码 ascii base64 binary hex latin1 utf8 utf-8 ucs2
ucs2 - utf16le 的别名。 base64 - Base64 编码。 latin1 - 一种把 Buffer 编码成一字节编码的字符串的方式。 binary - latin1 的别名。
---- Buffer 与字符编码 Buffer 实例一般用于表示编码字符的序列,比如 UTF-8 、 UCS2 、 Base64 、或十六进制编码的数据。 ucs2 - utf16le 的别名。 base64 - Base64 编码。 latin1 - 一种把 Buffer 编码成一字节编码的字符串的方式。 binary - latin1 的别名。