Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 123788
0 votes

Encoding to ASCII where original encoding of string is not known

You don’t know the encoding. You can assume that all encoded characters are valid and draw conclusions from that. If all bytes are from 32 to 126 then the encoding could be ASCII, some 8 bit encoding, …
gnasher729's user avatar
  • 47.5k
5 votes

Why should C++ uint8_t data not be printable?

If c is an unsigned char with a value of ‘A’ then printing c to std::cout prints the letter ‘A’. Printing c cast to int prints “65”. uint8_t has 256 different values. Printing each of them cast to int …
gnasher729's user avatar
  • 47.5k
1 vote

How is encoding handled correctly during copy-paste between programs?

A program transferring text can do one of three things: Transfer without telling which encoding is used, transfer using a standard encoding, or transfer while specifying the encoding. The receiving …
gnasher729's user avatar
  • 47.5k
0 votes

Compressing EBCDIC file vs UTF8

There is some extraordinary claim. One file of 336MB and one file of 335MB, containing the same data, one compressed to 26MB and one compressed to 16MB. That's a compression factor of 22 in one case …
gnasher729's user avatar
  • 47.5k
3 votes
Accepted

Does the SHA256 hashing algorithm change based on the content encoding?

SHA256 and practically all encryption methods operate on bytes. That is often impractical, so you might have a utility for example that encrypts a utf-8 encoded string by converting it to bytes and pr …
gnasher729's user avatar
  • 47.5k
3 votes

Why does UTF-8 waste several bits in its encoding

What hasn't been mentioned is that if you have a correct sequence of code points, and a pointer that is guaranteed to point to the first byte of a code point, with UTF-8 you can very easily find the p …
gnasher729's user avatar
  • 47.5k
1 vote

Should a Java project use UTF-16?

Java uses UTF-16 internally. But nobody needs to care about that, except for a tiny bit of efficiency. UTF-8 is much more what everyone uses as the standard for external representation.
gnasher729's user avatar
  • 47.5k
0 votes

How to detect the encoding of a file?

A special case is JSON documents. They are defined to be contain a sequence of Unicode code points encoded in UTF-8, UTF-16 BE or LE, or UTF-32 BE or LE, with optional BOM. Valid JSON documents have t …
gnasher729's user avatar
  • 47.5k
0 votes

How to detect the encoding of a file?

Assuming you have a file that is given to you just as a sequence of bytes, with no indication of the encoding, and you want to either determine an encoding consistent with the bytes, or reject the fil …
gnasher729's user avatar
  • 47.5k