3,357 questions
842
votes
12
answers
1.3m
views
Java URL encoding of query string parameters
Say I have a URL
http://example.com/query?q=
and I have a query entered by the user such as:
random word £500 bank $
I want the result to be a properly encoded URL:
http://example.com/query?q=...
353
votes
4
answers
740k
views
How can I convert a hex string to a byte array? [duplicate]
Can we convert a hex string to a byte array using a built-in function in C# or do I have to make a custom method for this?
1515
votes
16
answers
591k
views
When are you supposed to use escape instead of encodeURI / encodeURIComponent?
When encoding a query string to be sent to a web server - when do you use escape() and when do you use encodeURI() or encodeURIComponent():
Use escape:
escape("% +&=");
OR
use encodeURI(...
376
votes
14
answers
239k
views
How to get UTF-8 working in Java webapps?
I need to get UTF-8 working in my Java webapp (servlets + JSP, no framework used) to support äöå etc. for regular Finnish text and Cyrillic alphabets like ЦжФ for special cases.
My setup is the ...
190
votes
14
answers
415k
views
Changing default encoding of Python?
I have many "can't encode" and "can't decode" problems with Python when I run my applications from the console. But in the Eclipse PyDev IDE, the default character encoding is set to UTF-8, and I'm ...
164
votes
16
answers
400k
views
Java : How to determine the correct charset encoding of a stream
With reference to the following thread:
Java App : Unable to read iso-8859-1 encoded file correctly
What is the best way to programatically determine the correct charset encoding of an inputstream/...
210
votes
23
answers
167k
views
Microsoft Excel mangles Diacritics in .csv files?
I am programmatically exporting data (using PHP 5.2) into a .csv test file.
Example data: Numéro 1 (note the accented e).
The data is utf-8 (no prepended BOM).
When I open this file in MS Excel is ...
189
votes
4
answers
246k
views
Why should we NOT use sys.setdefaultencoding("utf-8") in a py script?
I have seen few py scripts which use this at the top of the script. In what cases one should use it?
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
87
votes
9
answers
130k
views
Convert a Unicode string to an escaped ASCII string
How can I convert this string:
This string contains the Unicode character Pi(π)
into an escaped ASCII string:
This string contains the Unicode character Pi(\u03a0)
and vice versa?
The current ...
16
votes
1
answer
4k
views
Different behaviour and output when piping in CMD and PowerShell
I am trying to pipe the content of a file to a simple ASCII symmetrical encryption program i made. It's a simple program that reads input from STDIN and adds or subtracts a certain value (224) to each ...
190
votes
6
answers
575k
views
UnicodeEncodeError: 'charmap' codec can't encode - character maps to <undefined>, print function [duplicate]
I am writing a Python 3.3 program to send some data to a webpage using POST method. Mostly for debugging process I am getting the page result and displaying it on the screen using print() function.
...
1060
votes
19
answers
589k
views
What is base 64 encoding used for?
I've heard people talking about "base 64 encoding" here and there. What is it used for?
182
votes
12
answers
178k
views
How to achieve Base64 URL safe encoding in C#?
I want to achieve Base64 URL safe encoding in C#. In Java, we have the common Codec library which gives me an URL safe encoded string. How can I achieve the same using C#?
byte[] toEncodeAsBytes = ...
155
votes
11
answers
268k
views
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, ...
258
votes
8
answers
630k
views
HTML encoding issues - "Â" character showing up instead of " "
I've got a legacy app just starting to misbehave, for whatever reason I'm not sure. It generates a bunch of HTML that gets turned into PDF reports by ActivePDF.
The process works like this:
Pull an ...
994
votes
21
answers
2.0m
views
Converting string to byte array in C#
I'm converting something from VB into C#. Having a problem with the syntax of this statement:
if ((searchResult.Properties["user"].Count > 0))
{
profile.User = System.Text.Encoding....
438
votes
5
answers
483k
views
URL decode UTF-8 in Python
In Python 2.7, given a URL like:
example.com?title=%D0%BF%D1%80%D0%B0%D0%B2%D0%BE%D0%B2%D0%B0%D1%8F+%D0%B7%D0%B0%D1%89%D0%B8%D1%82%D0%B0
How can I decode it to the expected result, example.com?title=...
781
votes
21
answers
442k
views
What is the difference between UTF-8 and Unicode?
I have heard conflicting opinions from people - according to the Wikipedia UTF-8 page.
They are the same thing, aren't they? Can someone clarify?
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-...
181
votes
6
answers
99k
views
Correct way to define Python source code encoding
PEP 263 defines how to declare Python source code encoding. Normally, the first 2 lines of a Python file should start with:
#!/usr/bin/python
# -*- coding: <encoding name> -*-
But I have seen a ...
505
votes
9
answers
412k
views
What are Unicode, UTF-8, and UTF-16?
What's the basis for Unicode and why the need for UTF-8 or UTF-16?
I have researched this on Google and searched here as well, but it's not clear to me.
In VSS, when doing a file comparison, sometimes ...
1288
votes
8
answers
1.2m
views
How can I do Base64 encoding in Node.js?
Does Node.js have built-in Base64 encoding yet?
The reason why I ask this is that final() from crypto can only output hexadecimal, binary or ASCII data. For example:
var cipher = crypto.createCipheriv(...
94
votes
11
answers
124k
views
Reading UTF-8 - BOM marker
I'm reading a file through a FileReader - the file is UTF-8 decoded (with BOM) now my problem is: I read the file and output a string, but sadly the BOM marker is outputted too. Why this occurs?
fr = ...
103
votes
23
answers
348k
views
How to convert a string with Unicode encoding to a string of letters
I have a string with escaped Unicode characters, \uXXXX, and I want to convert it to regular Unicode letters. For example:
"\u0048\u0065\u006C\u006C\u006F World"
should become
"Hello World"
I know ...
74
votes
8
answers
73k
views
How to replace Microsoft-encoded quotes in PHP
I need to replace Microsoft Word's version of single and double quotations marks (“ ” ‘ ’) with regular quotes (' and ") due to an encoding issue in my application. I do not need them to be HTML ...