832 questions
1083
votes
31
answers
2.7m
views
Reading a plain text file in Java
It seems there are different ways to read and write data of files in Java.
I want to read ASCII data from a file. What are the possible ways and their differences?
294
votes
11
answers
492k
views
What is ANSI format?
What is ANSI encoding format? Is it a system default format?
In what way does it differ from ASCII?
147
votes
10
answers
22k
views
What is the idea behind ^= 32, that converts lowercase letters to upper and vice versa?
I was solving some problem on codeforces. Normally I first check if the character is upper or lower English letter then subtract or add 32 to convert it to the corresponding letter. But I found ...
215
votes
18
answers
327k
views
How to remove all non printable characters in a string?
I imagine I need to remove chars 0-31 and 127.
Is there a function or piece of code to do this efficiently?
334
votes
12
answers
314k
views
Replace non-ASCII characters with a single space
I need to replace all non-ASCII (\x00-\x7F) characters with a space. I'm surprised that this is not dead-easy in Python, unless I'm missing something. The following function simply removes all non-...
205
votes
12
answers
548k
views
Convert Unicode to ASCII without errors in Python
My code just scrapes a web page, then converts it to Unicode.
html = urllib.urlopen(link).read()
html.encode("utf8","ignore")
self.response.out.write(html)
But I get a UnicodeDecodeError:
Traceback (...
269
votes
15
answers
304k
views
How to check if a string in Python is in ASCII?
I want to I check whether a string is in ASCII or not.
I am aware of ord(), however when I try ord('é'), I have TypeError: ord() expected a character, but string of length 2 found. I understood it is ...
421
votes
2
answers
376k
views
Unicode, UTF, ASCII, ANSI format differences
What is the difference between the Unicode, UTF8, UTF7, UTF16, UTF32, ASCII, and ANSI encodings?
In what way are these helpful for programmers?
112
votes
9
answers
231k
views
Regex any ASCII character
What is the regex to match xxx[any ASCII character here, spaces included]+xxx?
I am trying xxx[(\w)(\W)(\s)]+xxx, but it doesn't seem to work.
99
votes
13
answers
127k
views
How can I pretty-print ASCII tables with Python? [closed]
I'm looking for a way to pretty-print tables like this:
=======================
| column 1 | column 2 |
=======================
| value1 | value2 |
| value3 | value4 |
=======================
...
2
votes
4
answers
59k
views
Assembly, printing ascii number
I have a problem with my assembly code. I want to print number stored in register cx, but when i tried to print it, it printed ascii character instead of ascii number, so I decided to write a ...
56
votes
4
answers
39k
views
Python UnicodeDecodeError - Am I misunderstanding encode?
Any thoughts on why this isn't working? I really thought 'ignore' would do the right thing.
>>> 'add \x93Monitoring\x93 to list '.encode('latin-1','ignore')
Traceback (most recent call last)...
224
votes
10
answers
216k
views
(grep) Regex to match non-ASCII characters?
On Linux, I have a directory with lots of files. Some of them have non-ASCII characters, but they are all valid UTF-8. One program has a bug that prevents it working with non-ASCII filenames, and I ...
98
votes
11
answers
489k
views
Convert an int to ASCII character
I have
int i = 6;
and I want
char c = '6'
by conversion. Any simple way to suggest?
EDIT:
also i need to generate a random number, and convert to a char, then add a '.txt' and access it in an ...
121
votes
13
answers
197k
views
Integer ASCII value to character in BASH using printf
Character to value works:
$ printf "%d\n" \'A
65
$
I have two questions, the first one is most important:
How do I take 65 and turn it into A?
\'A converts an ASCII character to its value using ...
461
votes
16
answers
172k
views
Why do we use Base64? [duplicate]
Wikipedia says
Base64 encoding schemes are commonly used when there is a need to encode binary data that needs be stored and transferred over media that are designed to deal with textual data. This ...
49
votes
1
answer
39k
views
Non-ASCII characters in Matplotlib
I have a problem displaying non-ASCII characters in Matplotlib, these characters are rendered as small boxes instead of a proper font, it looks like (I filled these boxes with red paint to hightlight ...
82
votes
5
answers
59k
views
Removing non-ASCII characters from data files
I've got a bunch of csv files that I'm reading into R and including in a package/data folder in .rdata format. Unfortunately the non-ASCII characters in the data fail the check. The tools package has ...
203
votes
9
answers
667k
views
Convert from ASCII string encoded in Hex to plain ASCII?
How can I convert from hex to plain ASCII in Python?
Note that, for example, I want to convert "0x7061756c" to "paul".
89
votes
1
answer
30k
views
What is the difference between the `A` and `W` functions in the Win32 API?
What is the difference in calling the Win32 API function that have an A character appended to the end as opposed to the W character.
I know it means ASCII and WIDE CHARACTER or Unicode, but what is ...
173
votes
10
answers
164k
views
How many characters can UTF-8 encode?
If UTF-8 is 8 bits, does it not mean that there can be only maximum of 256 different characters?
The first 128 code points are the same as in ASCII. But it says UTF-8 can support up to million of ...
1
vote
3
answers
3k
views
How can I load 100 files with similar names and/or string in just one step in MATLAB?
I have 100 ASCII files in my directory all named as follows:
int_001.ASC
int_002.ASC
int_003.ASC
.
.
.
int_099.ASC
int_100.ASC
I have to import them in MATLAB all with importdata, ...
42
votes
3
answers
121k
views
Finding the Values of the Arrow Keys in Python: Why are they triples?
I am trying to find the values that my local system assigns to the arrow keys, specifically in Python. I am using the following script to do this:
import sys,tty,termios
class _Getch:
def ...
8
votes
3
answers
144k
views
Conversion of Char to Binary in C
I am trying to convert a character to its binary representation (so character --> ascii hex --> binary).
I know to do that I need to shift and AND. However, my code is not working for some reason.
...
53
votes
9
answers
98k
views
In Python, how do I decode GZIP encoding?
I downloaded a webpage in my python script.
In most cases, this works fine.
However, this one had a response header: GZIP encoding, and when I tried to print the source code of this web page, it had ...