unicode

字符编码(copy from linhaifeng)

孤人 提交于 2020-02-12 00:29:09
一 计算机基础知识 二 文本编辑器存取文件的原理(nodepad++,pycharm,word) #1、打开编辑器就打开了启动了一个进程,是在内存中的,所以,用编辑器编写的内容也都是存放与内存中的,断电后数据丢失 #2、要想永久保存,需要点击保存按钮:编辑器把内存的数据刷到了硬盘上。 #3、在我们编写一个py文件(没有执行),跟编写其他文件没有任何区别,都只是在编写一堆字符而已。 三 python解释器执行py文件的原理 ,例如python test.py #第一阶段:python解释器启动,此时就相当于启动了一个文本编辑器 #第二阶段:python解释器相当于文本编辑器,去打开test.py文件,从硬盘上将test.py的文件内容读入到内存中(小复习:pyhon的解释性,决定了解释器只关心文件内容,不关心文件后缀名) #第三阶段:python解释器解释执行刚刚加载到内存中test.py的代码( ps:在该阶段,即真正执行代码时,才会识别python的语法,执行文件内代码,当执行到name="egon"时,会开辟内存空间存放字符串"egon") 四 总结python解释器与文件本编辑的异同 #1、相同点:python解释器是解释执行文件内容的,因而python解释器具备读py文件的功能,这一点与文本编辑器一样 #2、不同点:文本编辑器将文件内容读入内存后,是为了显示或者编辑

字符编码

喜欢而已 提交于 2020-02-11 22:55:12
一 什么是字符编码   计算机要想工作必须通电,即用‘电’驱使计算机干活,也就是说‘电’的特性决定了计算机的特性。电的特性即高低电平(人类从逻辑上将二进制数1对应高电平,二进制数0对应低电平),关于磁盘的磁特性也是同样的道理。   结论:计算机只认识数字   很明显,我们平时在使用计算机时,用的都是人类能读懂的字符(用高级语言编程的结果也无非是在文件内写了一堆字符),如何能让计算机读懂人类的字符?   必须经过一个过程:   #字符--------(翻译过程)------->数字   #这个过程实际就是一个字符如何对应一个特定数字的标准,这个标准称之为字符编码. 二 字符编码的发展史与分类(了解) 计算机由美国人发明,最早的字符编码为ASCII,只规定了 英文字母数字和一些特殊字符与数字 的对应关系。最多只能用 8 位来表示(一个字节=1byte字节=8bit),即:2**8 = 256,所以,ASCII码最多只能表示 256 个符号 当然我们编程语言都用英文没问题,ASCII够用,但是在处理数据时,不同的国家有不同的语言,日本人会在自己的程序中加入日文,中国人会加入中文。 而要表示中文,单拿一个字节表表示一个汉字,是不可能表达完的(连小学生都认识两千多个汉字),解决方法只有一个,就是一个字节用>8位2进制代表,位数越多,代表的变化就多,这样,就可以尽可能多的表达出不通的汉字 所以

加密与解密学习笔记3-Windows与Unicode

前提是你 提交于 2020-02-11 18:36:50
windows 9x几乎都是使用ANSI字符串来进行所有内部操作。但也有少量函数支持Unicode的能力。 Win9x_Unicode.exe例子 #include <windows.h> #include <tchar.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdline, int iCmdShow) { MessageBox(NULL, TEXT("Windows 9x支持Unicode?"), TEXT("Hello"), 0); return 0; } 运行结果: 反汇编工具(W32Dasm)查看代码 :00411690 6A00 push 00000000 :00411692 68306B4100 push 00416B30 :00411697 68406B4100 push 00416B40 :0041169C 6A00 push 00000000 * Reference To: USER32.MessageBoxW, Ord:024Dh | :0041169E FF1598A04100 Call dword ptr [0041A098] :004116A4 3BF4 cmp esi, esp :004116A6 E859FAFFFF call

让SDL_ttf支持中文

♀尐吖头ヾ 提交于 2020-02-11 16:28:56
默认情况下、莪们可以使用TTF_RenderUTF8_Blended()函数来渲染UTF8文字到视频窗口中、但由于中文windows本地环境并非unicode编码而是gbk编码、这就涉及到多字节(双字节)转换成宽字节的问题了、因此还需要用一个小函数转化一下才能输出到SDL_tff中、注意其中使用到的函数要使用到windows.h头文件 char* localeToUTF8(char* src) { char* buf = NULL; int nRetLen = 0; wchar_t* unicode_buf = NULL; // *function: MultiByteToWideChar (Maps a character string to a UTF-16 (wide character) string.) // - UINT CodePage (Code page to use in performing the conversion. ) // CP_ACP: The system default Windows ANSI code page. // - DWORD dwFlags (Flags indicating the conversion type) // 0: // - LPCSTR lpMultiByteStr (Pointer to the

MySQL中文乱码修改

北战南征 提交于 2020-02-10 18:52:20
一、从服务端进行修改 show variables like "%char%"; 然后可能显示如下信息,注意红色部分,不同的用户可能实际情况不同,但是需要保证除了 filesystem为binary外,其他都为utf8: +--------------------------+---------------+ | Variable_name | Value | +--------------------------+---------------+ | character_set_client | gbk | | character_set_connection | gbk | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | gbk | | character_set_server | utf8 | | character_set_system | utf8 | +--------------------------+-------------+ 通过如下SQL语句进行修改,全部设置为utf8即可: #设置数据库编码信息 SET character_set_client='utf8'; SET character_set

基础数据类型补充以及编码的进阶

一笑奈何 提交于 2020-02-10 01:57:58
python 基础数据类型补充以及编码的进阶 一. 基础数据类型补充内容 1.1 字符串 字符串咱们之前已经讲了一些非常重要的方法,剩下还有一些方法虽然不是那么重要,但是也算是比较常用,在此给大家在补充一些,需要大家尽量记住。 #captalize :首字母大写        #swapcase :大小写翻转        #title   :每个单词的首字母大写 #center    :内同居中,总长度,空白处填充 #寻找字符串中的元素是否存在       #find     :返回的找到的元素的索引,如果找不到返回-1 #index     :返回的找到的元素的索引,找不到报错。 #captalize,swapcase,title print(name.capitalize()) #首字母大写 print(name.swapcase()) #大小写翻转 msg='taibai say hi' print(msg.title()) #每个单词的首字母大写 # 内同居中,总长度,空白处填充 ret2 = a1.center(20,"*") print(ret2) #寻找字符串中的元素是否存在 # ret6 = a4.find("fjdk",1,6) # print(ret6) # 返回的找到的元素的索引,如果找不到返回-1 # ret61 = a4.index("fjdk",4,6

Java equivalent to JavaScript's encodeURIComponent that produces identical output?

北城余情 提交于 2020-02-08 21:42:48
问题 I've been experimenting with various bits of Java code trying to come up with something that will encode a string containing quotes, spaces and "exotic" Unicode characters and produce output that's identical to JavaScript's encodeURIComponent function. My torture test string is: "A" B ± " If I enter the following JavaScript statement in Firebug: encodeURIComponent('"A" B ± "'); —Then I get: "%22A%22%20B%20%C2%B1%20%22" Here's my little test Java program: import java.io

Java equivalent to JavaScript's encodeURIComponent that produces identical output?

帅比萌擦擦* 提交于 2020-02-08 21:41:46
问题 I've been experimenting with various bits of Java code trying to come up with something that will encode a string containing quotes, spaces and "exotic" Unicode characters and produce output that's identical to JavaScript's encodeURIComponent function. My torture test string is: "A" B ± " If I enter the following JavaScript statement in Firebug: encodeURIComponent('"A" B ± "'); —Then I get: "%22A%22%20B%20%C2%B1%20%22" Here's my little test Java program: import java.io

Java equivalent to JavaScript's encodeURIComponent that produces identical output?

纵然是瞬间 提交于 2020-02-08 21:40:46
问题 I've been experimenting with various bits of Java code trying to come up with something that will encode a string containing quotes, spaces and "exotic" Unicode characters and produce output that's identical to JavaScript's encodeURIComponent function. My torture test string is: "A" B ± " If I enter the following JavaScript statement in Firebug: encodeURIComponent('"A" B ± "'); —Then I get: "%22A%22%20B%20%C2%B1%20%22" Here's my little test Java program: import java.io

Java equivalent to JavaScript's encodeURIComponent that produces identical output?

喜你入骨 提交于 2020-02-08 21:39:54
问题 I've been experimenting with various bits of Java code trying to come up with something that will encode a string containing quotes, spaces and "exotic" Unicode characters and produce output that's identical to JavaScript's encodeURIComponent function. My torture test string is: "A" B ± " If I enter the following JavaScript statement in Firebug: encodeURIComponent('"A" B ± "'); —Then I get: "%22A%22%20B%20%C2%B1%20%22" Here's my little test Java program: import java.io