ascii

ASCII码和BASE64

北战南征 提交于 2020-01-04 02:40:43
ASCII码介绍 ASCII ((American Standard Code for Information Interchange): 美国信息交换标准代码)是基于拉丁字母的一套电脑编码系统,主要用于显示现代英语和其他西欧语言。 到目前为止共定义了128个字符 用于将字符转换未二进制码 ASCII 码使用指定的 7 位或 8 位二进制数组合来表示 128 或 256 种可能的字符。标准 ASCII 码也叫基础ASCII码,使用 7 位二进制数来表示所有的大写和小写字母,数字 0 到 9、标点符号, 以及在美式英语中使用的特殊控制字符 通过一种通用的标准,使信息可以传入,一种二进制序列会被 识别未相同的结果 ASCII码表大致可以分三部分组成: ASCII非打印控制字符 ASCII表上的数字0–31分配给了控制字符,用于控制像打印机等一些外围设备。例如,12代表换页/新页功能。此命令指示打印机跳到下一页的开头。(参详ASCII码表中0-31) ASCII打印字符 数字 32–126 分配给了能在键盘上找到的字符,当您查看或打印文档时就会出现。数字127代表 DELETE 命令。(参详ASCII码表中32-127) 扩展ASCII打印字符 扩展的ASCII字符满足了对更多字符的需求。扩展的ASCII包含ASCII中已有的128个字符(数字0–32显示在下图中),又增加了128个字符

ASCII TABLE - negative value [duplicate]

我的梦境 提交于 2020-01-04 02:40:11
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Negative ASCII value int main() { char b = 8-'3'; printf("%c\n",b); return 0; } I run this program and I get a sign which looks like a question mark (?). My question to you is why is it prints that and not printing nothing, beacause as far as I know the value of b by the ASCII table is minus 43 which is not exist. by the way, when I compile this code: int main() { char b = -16; printf("%c\n",b); return 0; } I

Is it possible for Python to read non-ascii text from file?

点点圈 提交于 2020-01-04 02:11:06
问题 I have a .txt file that is UTF-8 formatted and have problems to read it into Python. I have a large number of files and a conversion would be cumbersome. So if I read the file in via for line in file_obj: ... I get the following error: File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 291: ordinal not in range(128) I

Hex characters in varchar() is actually ascii. Need to decode it

Deadly 提交于 2020-01-03 11:46:50
问题 This is such an edge-case of a question, I'd be surprised if there is an easy way to do this. I have a MS SQL DB with a field of type varchar(255). It contains a hex string which is actually a Guid when you decode it using an ascii decoder. I know that sounds REALLY weird but here's an example: The contents of the field: "38353334373838622D393030302D343732392D383436622D383161336634396339663931" What it actually represents: "8534788b-9000-4729-846b-81a3f49c9f91" I need a way to decode this,

How can I check if file is text (ASCII) or binary in C

牧云@^-^@ 提交于 2020-01-03 09:28:06
问题 I need to write C code that checks to see if a file is text(ASCII) or Binary Could someone help? Thanks 回答1: Typical method is to read the first several hundred bytes and look for ASCII NUL. If the file contains NUL, it is definitely a binary file. Most binary files do contain NUL bytes, but text files should never contain NUL bytes. #include <string.h> bool is_binary(const void *data, size_t len) { return memchr(data, '\0', len) != NULL; } Be warned that this is a heuristic. In other words,

Reading a mainframe EBCDIC File [closed]

删除回忆录丶 提交于 2020-01-03 02:50:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I have a EBCDIC coded mainframe file which I need to convert to an ASCII format. Which libraries/tools can I use to do that. I am most familiar with Python. The file I received has a cookbook with it, which can be used to parse the file (part of it is below). What do types: 'C', 'P' and 'B' mean? I'm guessing C

Convert an integer into a string of its ascii values

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-02 07:43:30
问题 Given a number number such that its digits are grouped into parts of length n (default value of n is 3) where each group represents some ascii value, I want to convert number into a string of those ascii characters. For example: n number Output ================================== 3 70 F 3 65066066065 ABBA 4 65006600660065 ABBA Note that there is no leading 0 in number, so the first ascii value will not necessarily be represented with n digits. My current code looks like this: def number_to

Python网络编程学习笔记(一)——UDP

烂漫一生 提交于 2020-01-02 03:11:57
代码清单2-1 使用自环接口的UDP服务器和客户端 import argparse, socket from datetime import datetime MAX_BYTES = 65535 def server(port): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind(('127.0.0.1', port)) print('Listening at {}'.format(sock.getsockname())) while True: data, address = sock.recvfrom(MAX_BYTES) text = data.decode('ascii') print('The client at {} says {!r}'.format(address, text)) text = 'Your data was {} bytes long'.format(len(data)) data = text.encode('ascii') sock.sendto(data, address) def client(port): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) text = 'The time is {}

手把手教你图片转ASCII码图

橙三吉。 提交于 2020-01-01 23:50:53
效果图 基本思路 把图片每个像素点的信息拿出来,最重要的是拿到rgb的值 把每个像素点由rgb转成灰度图像,即0-255 给0-255分级,把每个等级的像素点转换成ascii码,完成 实现 第一步:获取像素信息 经查阅,使用canvas的getImageData方法可完成此要求,如下 <canvas id="canvas"></canvas> <script> var canvas=document.getElementById("canvas"); var context=canvas.getContext("2d"); canvas.width=800; canvas.height=800; context.rect(0,0,800,800); context.fillStyle="red"; context.fill(); console.log(context.getImageData(0,0,800,800)) </script> 上述代码指在canvas中铺满背景色为red,同时用getImageData()方法输出整个画布800*800的每个像素点。在控制台我们可以看到console的结果: 我们看到长度为2560000,而我们的宽*高才640000,这是怎么回事,难道不是一个像素点对应getImageData()中的一位?我们把2560000/640000

color single lines of ASCII characters with batch CMD

大城市里の小女人 提交于 2020-01-01 20:49:26
问题 I was recently overwhelmed with quick responses for a question I had the other day! hopefully this will be a quick one for those in the know, I've searched and played for hours and just not getting it. I have found code to modify color per character in batch CMD although cant make it work for ASCII characters. This shows hows output window with errors: Here's the code I've tried to modify to suit, it explains exactly whats happening and what im attempting: @echo off SETLOCAL