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
155
votes
10 answers

Is a URL allowed to contain a space?

Is a URI (specifically an HTTP URL) allowed to contain one or more space characters? If a URL must be encoded, is + just a commonly followed convention, or a legitimate alternative? In particular, can someone point to an RFC that indicates that a…
Joe Casadonte
  • 15,888
  • 11
  • 45
  • 57
151
votes
11 answers

Base64 encoding in SQL Server 2005 T-SQL

I'd like to write a T-SQL query where I encode a string as a Base64 string. Surprisingly, I can't find any native T-SQL functions for doing Base64 encoding. Does a native function exist? If not, what's the best way to do Base64 encoding in T-SQL?
Jacob
  • 77,566
  • 24
  • 149
  • 228
148
votes
15 answers

How to get ASCII value of string in C#

I want to get the ASCII value of characters in a string in C#. If my string has the value "9quali52ty3", I want an array with the ASCII values of each of the 11 characters. How can I get ASCII values in C#?
RBS
  • 3,801
  • 11
  • 35
  • 33
143
votes
12 answers

How to support UTF-8 encoding in Eclipse

How can I add UTF-8 support in eclipse? I want to add for example Russian language but eclipse won't support it. What should I do? Please guide me.
Katty
  • 1,707
  • 3
  • 13
  • 18
143
votes
6 answers

Why does Python print unicode characters when the default encoding is ASCII?

From the Python 2.6 shell: >>> import sys >>> print sys.getdefaultencoding() ascii >>> print u'\xe9' é >>> I expected to have either some gibberish or an Error after the print statement, since the "é" character isn't part of ASCII and I haven't…
Michael Ekoka
  • 19,050
  • 12
  • 78
  • 79
142
votes
2 answers

Should I use encoding declaration in Python 3?

Python 3 uses UTF-8 encoding for source-code files by default. Should I still use the encoding declaration at the beginning of every source file? Like # -*- coding: utf-8 -*-
Mateusz Jagiełło
  • 6,854
  • 12
  • 40
  • 46
142
votes
10 answers

Determine a string's encoding in C#

Is there any way to determine a string's encoding in C#? Say, I have a filename string, but I don't know if it is encoded in Unicode UTF-16 or the system-default encoding, how do I find out?
krebstar
  • 3,956
  • 8
  • 46
  • 64
140
votes
11 answers

How can I safely encode a string in Java to use as a filename?

I'm receiving a string from an external process. I want to use that String to make a filename, and then write to that file. Here's my code snippet to do this: String s = ... // comes from external source File currentFile = new…
Steve McLeod
  • 51,737
  • 47
  • 128
  • 184
137
votes
6 answers

Java FileReader encoding issue

I tried to use java.io.FileReader to read some text files and convert them into a string, but I found the result is wrongly encoded and not readable at all. Here's my environment: Windows 2003, OS encoding: CP1252 Java 5.0 My files are UTF-8…
nybon
  • 8,894
  • 9
  • 59
  • 67
137
votes
13 answers

"unmappable character for encoding" warning in Java

I'm currently working on a Java project that is emitting the following warning when I compile: /src/com/myco/apps/AppDBCore.java:439: warning: unmappable character for encoding UTF8 [javac] String copyright = "� 2003-2008 My Company. All…
seanhodges
  • 17,426
  • 15
  • 71
  • 93
126
votes
6 answers

How to set standard encoding in Visual Studio

I am searching for a way to setup Visual Studio so it always saves my files in UTF-8. I have only found options to set this project wide. Is there a way to set it Visual Studio wide?
Thomaschaaf
  • 17,847
  • 32
  • 94
  • 128
123
votes
5 answers

Why declare unicode by string in python?

I'm still learning python and I have a doubt: In python 2.6.x I usually declare encoding in the file header like this (as in PEP 0263) # -*- coding: utf-8 -*- After that, my strings are written as usual: a = "A normal string without declared…
CastleDweller
  • 8,204
  • 13
  • 49
  • 69
123
votes
3 answers

Set encoding and fileencoding to utf-8 in Vim

What is the difference between these two commands? set encoding=utf-8 set fileencoding=utf-8 Do I need to set both when I want to use utf-8? Also, do I need to set fileencoding with set or setglobal?
Kiraly Zoltan
  • 1,383
  • 3
  • 10
  • 7
122
votes
2 answers

Content Transfer Encoding 7bit or 8 bit

While sending email content, it is required to set "Content Transfer Encoding" header. I observed many headers of emails that I received. Some emails using "7bit" and some are using "8bit". What is the difference between these two? Which is…
mahi
  • 1,221
  • 2
  • 9
  • 3
121
votes
10 answers

Write text files without Byte Order Mark (BOM)?

I am trying to create a text file using VB.Net with UTF8 encoding, without BOM. Can anybody help me, how to do this? I can write file with UTF8 encoding but, how to remove Byte Order Mark from it? edit1: I have tried code like this; Dim utf8…
VJOY
  • 3,752
  • 12
  • 57
  • 90