Questions tagged [encoding]

Encoding is a set of predefined rules to reversibly transform a piece of information in a certain representation into a completely different representation. The other way round is called decoding. This tag is rather generic, but it is mainly used for binary encoding schemes such as base 64 and hexadecimal.

There are a lot of different applications:

  • which is how the computer represents characters like a and , which humans can recognize, into bytes, which computers can recognize.
  • which is used to transform between videos and bytes.
  • which is used to transform between plain text and valid URIs. Also known as .
  • which is used to transform between plain text and valid XML.
  • which is used to compress/decompress bytes.
24174 questions
7
votes
1 answer

Is there a difference between `%`-format operator and `str.format()` in python regarding unicode and utf-8 encoding?

Assume that n = u"Tübingen" repr(n) # `T\xfcbingen` # Unicode i = 1 # integer The first of the following files throws UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 82: ordinal not in range(128) When I do…
Aufwind
  • 25,310
  • 38
  • 109
  • 154
7
votes
2 answers

PHP string to hex

I have a string like that: [0-9A-Za-z\+/=]* How can I converted in the following form: "\133\x30\55\x39\101\x2d\132\x61\55\x7a\134\x2b\57\x3d\135\x2a" Is there any function for that ?
KodeFor.Me
  • 13,069
  • 27
  • 98
  • 166
7
votes
2 answers

How to GetBytes from string appropriately?

I have a string variable from which I get the following bytes with the following loop: Bytes I get: 1e 05 55 3c *e2 *91 6f 03 *fe 1a 1d *f4 51 6a 5e 3a *ce *d1 04 *8c With that loop: byte[] temp = new byte[source.Length]; string x = ""; for…
John
  • 1,834
  • 5
  • 32
  • 60
7
votes
3 answers

PHP Regex validate letters and Spanish accent

How can I add/improvised my code so Spanish accent will be considered as valid in addition to normal alphabet (a-z) I have the following in my code public static function IsAlpha($s){ $reg = "#[^a-z\s-]#i"; $count = preg_match($reg, $s,…
xar
  • 1,429
  • 2
  • 17
  • 29
7
votes
4 answers

Cannot replace £ with £ from string

I have a HTML string containing £ signs, for some reason i'm not able to replace them. I'm assuming this is an encoding issue although i can't work out how. The site is using ISO-8859-1 for its encoding $str = '
robjmills
  • 18,438
  • 15
  • 77
  • 121
7
votes
2 answers

Change file encoding without information losses in intellij idea

Is it possible to change file's encoding from UTF-8 to windows1251 without cyrillic information lost. Because when I explicitely change the encoding, all cyrillic symbols become unreadable?
Sergey
  • 11,548
  • 24
  • 76
  • 113
7
votes
2 answers

Viterbi decoder

Does anyone know for any good resource on the web or book where the explanation for Viterbi decoder or a tutorial on how to decode a received bit sequence by using trellis diagram could be found? Thanks!
Niko Gamulin
  • 66,025
  • 95
  • 221
  • 286
7
votes
3 answers

char vs wchar_t

I'm trying to print out a wchar_t* string. Code goes below: #include #include #include char *ascii_ = "中日友好"; //line-1 wchar_t *wchar_ = L"中日友好"; //line-2 int main() { printf("ascii_: %s\n", ascii_); //line-3 …
Alcott
  • 17,905
  • 32
  • 116
  • 173
7
votes
1 answer

How to decode quotable chars (from quotable to a char)?

I have a text with quoted-printables. Here is an example of such a text (from a wikipedia article): If you believe that truth=3Dbeauty, then surely=20= mathematics is the most beautiful branch of philosophy. I am looking for a Java class, which…
Skarab
  • 6,981
  • 13
  • 48
  • 86
7
votes
1 answer

C# Encoding.Converting Latin to Hebrew

I'm trying to fetch and parse an online excel document which is written in hebrew but unfortunately in a non-hebrew encoding. As an example I'm trying to convert the following string: "âìéåï_1", which serves as the 1st sheet name to hebrew using C#…
Mikey S.
  • 3,301
  • 6
  • 36
  • 55
7
votes
1 answer

Why do I get an unmappable character for encoding UTF-8 when I changed maven java compiler plugin from 1.5 to 1.6?

I have a Java project and I'm using Apache Maven. All this time I was using Maven Java compiler plugin with parameters source=1.5 and target=1.5 defined in pom.xml file. Since I changed it to source=1.6 and target=1.6 I'm getting the following…
joragupra
  • 692
  • 1
  • 12
  • 23
7
votes
1 answer

converting .mov file to .h264 file

ok, this is the case, i actually want to parse frames from a mov file. get the encoded h264 frames. and i've managed to do so by using ffmpeg but when i try to make a movie again by using ffmpeg -i test* test.mov i get test00: Invalid data found…
Robin Rye
  • 480
  • 1
  • 7
  • 20
7
votes
0 answers

How can I best use UTF-8 for text in Windows program development?

I've just started doing some Windows programming. I'm trying to decide how best to handle non-ASCII text. I'd prefer to use 8-bit characters rather than 16-bit i.e. declare all my strings as char. I've read the UTF-8 Everywhere proposals, and I…
AndyK
  • 464
  • 5
  • 6
7
votes
8 answers

How to guess the encoding of a file with no BOM in .NET?

I'm using the StreamReader class in .NET like this: using( StreamReader reader = new StreamReader( "c:\somefile.html", true ) { string filetext = reader.ReadToEnd(); } This works fine when the file has a BOM. I ran into trouble with a file…
user70602
7
votes
2 answers

How to encode all logged messages as utf-8 in Python

I have a little logger function that returns potentially two handlers to log to a RotatingFileHandler and sys.stdout simultaneously. import os, logging, sys from logging.handlers import RotatingFileHandler from config import * def…
Midnight
  • 373
  • 2
  • 11