找回密码
 加入
搜索
查看: 1630|回复: 5

请问如何获取汉字内码?

[复制链接]
发表于 2009-5-31 21:23:26 | 显示全部楼层 |阅读模式
比如:人(C8CB)生(C9FA)如(C8E7)梦(C3CE),怎样得到括号内的内码?
发表于 2009-5-31 22:07:13 | 显示全部楼层
#include <string.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#AutoIt3Wrapper_UseAnsi=y
$Form1 = GUICreate("汉字内码转换演示", 280, 113, 192, 124)
$Input1 = GUICtrlCreateInput("请输入汉字", 56, 16, 129, 21)
$Input2 = GUICtrlCreateInput("汉字内码结果", 56, 48, 129, 21)
$Label1 = GUICtrlCreateLabel("汉字", 8, 16, 36, 17)
$Label2 = GUICtrlCreateLabel("内码", 8, 48, 36, 17)
$Button = GUICtrlCreateButton("转换", 200, 24, 49, 33, 0)
$Label3 = GUICtrlCreateLabel("注意:必需编译之后才能正常运行", 54, 80, 184, 17)
GUISetState(@SW_SHOW)
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
        Case $Button
   $String = GUICtrlRead($Input1)
            $Hex = _StringToHex($String)
   GUICtrlSetData($Input2,$Hex)
 EndSwitch
WEnd

切记:必需编译之后才能运行,否则只会显示内码的前两位而已
这是脚本编译方式的问题,必需要使用ANSI编译方式#AutoIt3Wrapper_UseAnsi=y

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-5-31 22:08:33 | 显示全部楼层
_StringToHex
--------------------------------------------------------------------------------
Convert a string to a hex string.
#Include <String.au3>
_StringToHex($strChar)
 楼主| 发表于 2009-5-31 22:17:37 | 显示全部楼层
呵呵,谢谢!刚刚已经找到最简单的办法了:

$bin = Binary("人生如梦")
$str = String($bin)
MsgBox(0,"人生如梦",$str)
 楼主| 发表于 2009-5-31 22:19:39 | 显示全部楼层
不过好像一次只能转换两个汉字?
发表于 2009-6-1 01:31:17 | 显示全部楼层
补上汉字等量任意字符
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 03:29 , Processed in 0.073484 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表