API与宽字符

API与宽字符 API(Application Programming Interface,应用程序编程接口) Api的定义 api就是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或者硬件的一访问一组例程的能力,而又无需访问源码,或者理解内部工作机制的细节 WindowsAPI的定义 WindowsAPI是一套用来控制windows的各个木粉的外观和行为的预先定义的WIndows函数 应用程序接口

win32中的宽字符

win32中的宽字符 宽字符 数据类型 容器、模板 ASCII 一个字符 一个字节 GB码(扩展了的ASCII) 英文字符 一个字节 GB码 中文字符 两个字节 UNICODE字符集(unicode编码实际指的是utf-16) 常用字符 两个字节 宽字符: 用多个字节来表示的字符称之为宽字符(只要不是以单字节存储都可称为宽字符)

unicode和utf8编码

兼容问题 由于ASCII存在字符含量过少的缺陷,所以不但我国自己搞出了国际码。其他国家也都设计出了符合自己国情的字符集 但是这就带来了问题 各个字符集之间不兼容怎么办? Unicode Unicode 4个字节32位 真正有效范围: 0x0 – 0x 10ffff 约十进制:1114112 个字符 unicode相当于 “区位码”(也就是电脑中运行的),实际存储要按照相应的编码方案

GB2312原文到GB2312机内码

GB2312原文到GB2312机内码 ANSCII 汉字编码国家标准 区位码 01-09区 为特殊字符区 10-15区 为自定义区 16-87区 为汉字编码区 兼容演变: 1. 区位码标准中没有定义控制字符 解决方案: 将整个区位码向后移动32位(具体表现为每一字节都加上0x20)得到GB2312原码(国标码) 2. 原版ASCII与我们的初版国际码不兼容 解决方案: 将整个BG2312源码向后移动0x80(具体表现为每一字节都加上0x80)得到GB2312机内码

Cpp9 模板

模板 下面是一个针对int的冒泡排序 // _20180301.cpp : Defines the entry point for the console application. // #include "stdafx.h" void Sort(int* arr,int nLength) { int i,k; for (i = 0;ix > base.x && this->y > base.y; } private: int x; int y; }; template void Sort(T* arr,int nLength) { int i,k; for (i = 0;iy) return …

Cpp8 运算符重载和深浅拷贝

深浅拷贝 相同类型间可以直接拷贝 // _20180212.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include class A { private: int* a; public: A() { a = new int[10]; } virtual ~A() { delete a; printf("析构 A \n"); } }; int main(int argc,char* argv[]) { A a1; A a2; a1 = a2; return …

Ruby11 拾遗

Agenda Loop Expression File Read/Write Debug Process & Thread Loop while a = 10 while a > 0 puts a a -= 1 end until a = 100 until a == 0 puts a a -= 1 end loop a = 10 loop do break if a 0 !~ 正则匹配 是否匹配不到 匹配到返回fals 匹配不到返回true /666/i !~ "hello world" # => true alias 别名 def hello "hello" end alias …

Ruby10 Class Module Gem 深入

Agenda class_eval & instance_eval method_missing Module as a namespace Gems require vs load $LOAD_PATH class_eval 首先class_eval是只有类才能调用的,Class#class_eval class_eval会重新打开当前类的作用域 # class_eval class User end User.class_eval do attr_accessor :name def hello "hello" end end user = User.new user.name = …

Ruby9 Class & Modules 进阶

Ruby的内部类结构 Array.class # => Class Class.class # => Class superclass 查看父类 Array.superclass # =>Object Object.superclass # =>BasicObject BasicObject.superclass # => nil ancestors 查看当前类的继承链 Array.ancestors # => [Array, Enumerable, Object, Kernel, BasicObject] Method Finding 方法查找 # class structure, …

Ruby8 继承(Inheritance)和模块(Modules)

继承示例 # inheritance class User attr_accessor :name, :age def initialize name, age @name, @age = name, age end def panels # ||= 操作符, 如果变量不存在 那么就赋值 @panels ||= ["Profile", "Products"] end end class Admin < User def panels @panels ||= ["Profile", "Products", "Manage Users", "System Setup"] end end user …

Ruby7 OOP

Everything is Object 一切皆对象 1 2 3 4 5 6 7 a = "hello" a.class # => String b = 3.14 b.class # => Float c = %w[pear cat horse] c.class # => Array Instance Method & Instance Attribute 实例方法,实例属性 Instance Method: 实例方法,成员方法,成员函数 Instance Attribute: 实例变量,成员属性,属性(property),使用@定义 1 2 3 4 5 6 7 8 9 10 11 12 13 …

Ruby6 细节补充

代码规范 使用UTF-8编码 使用空格缩进,不使用tab, 1 tab = 2 spaces 不需要使用分号(;)和反斜杠()连接代码 Demo # basic types a = 1 b = "hello world" # one line c = ["pear", "cat", "dog"] # or multiple lines c2 = [ "pear", "cat", "dog" ] d = { name:"world", age:18 } d2 = { name:"world", age:18 } # source layout, conversion # with or …

Ruby5 其他的奇技淫巧

变量赋值 # 变量交换 a = 1 b = 2 b,a = a,b puts a puts b puts "-" * 30 x = [1, 2, 3] a, b = x #默认会把数组中的值依次赋值给 a ,b puts a puts b puts "-" * 30 x = [1, 2, 3] a, *b = x #这里a会接受第一个元素 b用了*号 表示接受剩下所有的元素 puts a p b #output 2 1 ------------------------------ 1 2 ------------------------------ 1 [2, 3] Fixnum & …

Ruby4 Blocks and Exceptions

Block 代码块 Block是一个参数 匿名参数 Callback 使用do/en或者{}来定义 {puts "hello"} Demo: # block usage def hello puts "hello method start" yield yield puts "hello method end" end hello {puts "i am in block"} #output hello method start i am in block i am in block hello method end # yield with parameter def hello puts …

Ruby3 流程控制

if/else/elsif 1 2 3 4 5 6 7 8 9 a = "hello" b = false if a p a elsif b p b else p "ok" end unless unless相当于if的反向断言 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 unless false "ok" end # => "ok" ## if/unless a = 1 if a != 1 #如果a不是1 则a复制为1 b = 2 unless defined?(b) #如果 …

Ruby1 数据类型,变量

整数类型: 3,222 小数: 3.14 字符串: hello,world 布尔类型: true(TrueClass),false(FalseClass) 数组: [1,2],["hello","hello world"] Hash(字典): {"name"=>"luo","age"=>24},{:name=>"daoyi",:age=>24} Symbol(符号): :a,:hello,:"hello world" Range: 1..10,1...10(三个点不包括10本身) 正则: /hello/i String 字符串 1 2 3 4 5 a = "hello" #=> hello …

Ruby2 Method and Block

Method(Function) 1 2 3 4 5 6 7 8 9 def hi(name) p "hi " + name end hi("666") # => "hi 666" hi "code" #括号省略 => "hi code" def hello name p "hello #{name}" end hello "world" # => "hello world" Method 参数 1 2 3 4 5 6 7 8 9 def hi name="code" p "hi " +name end hi # => "hi code" def hi name,age=32 p …

Cpp7 C++的多态实现 — 虚表

多态的实现原理 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 #include "stdafx.h" #include #include class A { public: int x; virtual void Test() { …

Cpp6 封装、继承和多态

继承 子类从父类继承成员变量 子类从父类继承成员函数 #include "stdafx.h" class Person { public: int Age; int Sex; void Word() { printf("Person:Work"); } }; class Teacher:public Person { public: int Level; }; int main() { Teacher t; t.Age = -1; //合法但是不合理 t.Sex = 2; t.Level = 3; return 0; } 实现数据隐藏 为什么要隐藏数据成员 与前面比较,赋值的时候 合理不合法, …

kali rolling 国内源

#阿里云kali源 deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib deb http://mirrors.aliyun.com/kali-security kali-rolling/updates main contrib non-free deb-src http://mirrors.aliyun.com/kali-security …