ascii

Python 3 itertools.islice continue despite UnicodeDecodeError

扶醉桌前 提交于 2021-01-28 00:01:03
问题 I have a python 3 program that monitors a log file. The log includes, among other things, chat messages written by users. The log is created by a third party application which I cannot change. Today a user wrote "텋��텋��" and it caused the program to crash with the following error: future: <Task finished coro=<updateConsoleLog() done, defined at /usr/local/src/bserver/logmonitor.py:48> exception=UnicodeDecodeError('utf-8',... say "\xed\xa0\xbd\xed\xb1\x8c"\r\n', 7623, 7624, 'invalid

how to display a number that is a char

孤街醉人 提交于 2021-01-27 21:03:43
问题 I have a multi-dimensional array of chars that I want to display. one of the dimensions has numbers in it (0, 1, 2, etc.). When I go to display the array, I get the ascii results. I realize the char output works as defined (char + number = ascii) but I was looking to specifically show the number. Ex. char a = 3; cout << a; // gives me # I want to display 3. I have tried casting to an int: cout << (int)a; I have tried casting inside the array myArray[(int)a]; Neither of those have seemed to

Javascript unicode to ASCII

核能气质少年 提交于 2021-01-27 17:26:59
问题 Need to convert the unicode of the SOH value '\u0001' to Ascii. Why is this not working? var soh = String.fromCharCode(01); It returns '\u0001' Or when I try var soh = '\u0001' It returns a smiley face. How can I get the unicode to become the proper SOH value(a blank unprintable character) 回答1: JS has no ASCII strings, they're intrinsically UTF-16. In a browser you're out of luck. If you're coding for node.js you're lucky! You can use a buffer to transcode strings into octets and then

Count lines in ASCII file using C

丶灬走出姿态 提交于 2021-01-27 16:06:02
问题 I would like to count the number of lines in an ASCII text file. I thought the best way to do this would be by counting the newlines in the file: for (int c = fgetc(fp); c != EOF; c = fgetc(fp)) { /* Count word line endings. */ if (c == '\n') ++lines; } However, I'm not sure if this would account for the last line on all both MS Windows and Linux. That is if my text file finishes as below, without an explicit newline, is there one encoded there anyway or should I add an extra ++lines; after

Count lines in ASCII file using C

一笑奈何 提交于 2021-01-27 15:53:25
问题 I would like to count the number of lines in an ASCII text file. I thought the best way to do this would be by counting the newlines in the file: for (int c = fgetc(fp); c != EOF; c = fgetc(fp)) { /* Count word line endings. */ if (c == '\n') ++lines; } However, I'm not sure if this would account for the last line on all both MS Windows and Linux. That is if my text file finishes as below, without an explicit newline, is there one encoded there anyway or should I add an extra ++lines; after

How to include a carriage return in an argument to an executable?

五迷三道 提交于 2021-01-27 10:00:24
问题 I have a simple program that prints out argv character by character, and I want to pass in carriage return ( '\r' or ASCII# 0x0D) as a program argument. How do I achieve this in linux OS (Ubuntu)? I am using bash. #include <stdio.h> #include <string.h> int main(int argc, char* argv[]) { int i; for(i = 1; i < argc; i++) { char* curr = argv[i]; while(*curr != '\0') { printf("[%c %x] ", *curr, *curr); curr++; } printf("\n"); } return 0; } Assuming our executable program is called test , if the

c# serialization ascii confusion

我是研究僧i 提交于 2021-01-27 07:43:37
问题 Here's the code. [Serializable] public class HostedGame { public int ID { get; set; } public int UID { get; set; } public String Name { get; set; } public Boolean Available { get; set; } public String Description { get; set; } public List<int> Users { get; set; } public int Port { get; set; } public HostedGame(int uid, String name, String description, int port) { UID = uid; Name = name; Description = description; Available = true; Port = port; Users = new List<int>(); } public int CompareTo

c# serialization ascii confusion

我只是一个虾纸丫 提交于 2021-01-27 07:41:45
问题 Here's the code. [Serializable] public class HostedGame { public int ID { get; set; } public int UID { get; set; } public String Name { get; set; } public Boolean Available { get; set; } public String Description { get; set; } public List<int> Users { get; set; } public int Port { get; set; } public HostedGame(int uid, String name, String description, int port) { UID = uid; Name = name; Description = description; Available = true; Port = port; Users = new List<int>(); } public int CompareTo

Continous alphabetic list in python and getting every value of it

三世轮回 提交于 2021-01-27 05:45:11
问题 I've almost the same problem like this one: How to make a continuous alphabetic list python (from a-z then from aa, ab, ac etc) But, I am doing a list in gui like excel, where on the vertical header should be letters ...aa,ab,ac....dg,dh,di... To do it, I have to declare every place on my list to certain letter. It is probably impossible with yield. I mean, let me say, I have 100 of cells and I want to name them all differently. Cell 1 should be "A", Cell 2 should be "B".... Cell 27 should be

Convert fancy/artistic unicode text to ASCII

穿精又带淫゛_ 提交于 2021-01-19 08:56:24
问题 I have a unicode string like "𝖙𝖍𝖚𝖌 𝖑𝖎𝖋𝖊" and would like to convert it to the ASCII form "thug life". I know I can achieve this in Python by import unidecode print(unidecode.unidecode('𝖙𝖍𝖚𝖌 𝖑𝖎𝖋𝖊')) // thug life However, this would asciify also other unicode characters (such as Chinese/Japanese characters, emojis, accented characters, etc.), which I want to preserve. Is there a way to detect these type of "artistic" unicode characters? Some more examples: 𝓽𝓱𝓾𝓰 𝓵𝓲𝓯𝓮 𝓉𝒽𝓊𝑔 𝓁𝒾𝒻𝑒 𝕥𝕙𝕦𝕘 𝕝𝕚𝕗𝕖 thug life