Active2 months ago
Exactly, the picture sequence will be converted into ASCII codes. This code was created to represent text in computer with 128 characters. Picture after been generated, will be represented as plain Text or as Html Code. Converting a name to ASCII is simple. There is no way to represent a string with a single ASCII number, but it is possible to store a name with several ASCII numbers representing each character in the string. In order to do so, simply convert each character in the string to its respective ASCII code.
What is the fastest, easiest tool or method to convert text files between character sets?
Specifically, I need to convert from UTF-8 to ISO-8859-15 and vice versa.
Everything goes: one-liners in your favorite scripting language, command-line tools or other utilities for OS, web sites, etc.
Convert Text Into Ascii
Best solutions so far:
On Linux/UNIX/OS X/cygwin:
- Gnu iconv suggested by Troels Arvin is best used as a filter. It seems to be universally available. Example:As pointed out by Ben, there is an online converter using iconv.
- Gnu recode (manual) suggested by Cheekysoft will convert one or several files in-place. Example:This one uses shorter aliases:Recode also supports surfaces which can be used to convert between different line ending types and encodings:Convert newlines from LF (Unix) to CR-LF (DOS):Base64 encode file:You can also combine them.Convert a Base64 encoded UTF8 file with Unix line endings to Base64 encoded Latin 1 file with Dos line endings:
On Windows with Powershell (Jay Bazuzi):
PS C:> gc -en utf8 in.txt | Out-File -en ascii out.txt
(No ISO-8859-15 support though; it says that supported charsets are unicode, utf7, utf8, utf32, ascii, bigendianunicode, default, and oem.)
Edit
Do you mean iso-8859-1 support? Using 'String' does this e.g. for vice versa
Note: The possible enumeration values are 'Unknown, String, Unicode, Byte, BigEndianUnicode, UTF8, UTF7, Ascii'.
- CsCvt - Kalytta's Character Set Converter is another great command line based conversion tool for Windows.
16 Answers
Stand-alone utility approach
You don't have to specify either of these arguments. They will default to your current locale, which is usually UTF-8.
Boris2,01722 gold badges2222 silver badges3333 bronze badges
Troels ArvinTroels Arvin4,50622 gold badges2020 silver badges2626 bronze badges
If you have
vim
you can use this:Not tested for every encoding.
The cool part about this is that you don't have to know the source encoding
Be aware that this command modify directly the file
Explanation part!
+
: Used by vim to directly enter command when opening a file. Usualy used to open a file at a specific line:vim +14 file.txt
|
: Separator of multiple commands (like;
in bash)set nobomb
: no utf-8 BOMset fenc=utf8
: Set new encoding to utf-8 doc linkx
: Save and close filefilename.txt
: path to the file'
: qotes are here because of pipes. (otherwise bash will use them as bash pipe)
Under Linux you can use the very powerful recode command to try and convert between the different charsets as well as any line ending issues. recode -l will show you all of the formats and encodings that the tool can convert between. It is likely to be a VERY long list.
CheekysoftCheekysoft27.1k1717 gold badges6363 silver badges8282 bronze badges
Also there are iconv-based tools in many languages.
whoan6,51944 gold badges2828 silver badges4343 bronze badges
Daniel PapasianDaniel Papasian14.8k66 gold badges2525 silver badges3232 bronze badges
The shortest version, if you can assume that the input BOM is correct:
David Martin9,01411 gold badge3737 silver badges6363 bronze badges
Jay BazuziJay Bazuzi32.6k1010 gold badges9595 silver badges158158 bronze badges
I've put this into
.bashrc
:.to be able to convert files like so:
On Windows I was able to use Notepad++ to do the conversion from ISO-8859-1 to UTF-8. Click
'Encoding'
and then 'Convert to UTF-8'
.The character encoding of all matching text files gets detected automatically and all matching text files are converted to
utf-8
encoding:To perform these steps, a sub shell
sh
is used with -exec
, running a one-liner with the -c
flag, and passing the filename as the positional argument '$1'
with -- {}
. In between, the utf-8
output file is temporarily named converted
.Whereby
file -bi
means:-b
,--brief
Do not prepend filenames to output lines (brief mode).-i
,--mime
Causes the file command to output mime type strings rather than the more traditional human readable ones. Thus it may say for exampletext/plain; charset=us-ascii
rather thanASCII text
. Thesed
command cuts this to onlyus-ascii
as is required byiconv
.
The
find
command is very useful for such file management automation.Click here for more find
galore.user15096user15096
DOS/Windows: use Code page
Command
chcp
can be used to change the code page. Code page 65001 is Microsoft name for UTF-8. After setting code page, the output generated by following commands will be of code page set.Ascii To Text Converter Online
to write properties file (Java) normally I use this in linux (mint and ubuntu distributions):
PS: I writed Execution number one/two in portugues to force special characters.
In my case, in first execution I received this message: What is undefined.
When I installed the first option (gcj-5-jdk) the problem was finished.
I hope this help someone.
With ruby:
Source: https://robots.thoughtbot.com/fight-back-utf-8-invalid-byte-sequences
Use this Python script: https://github.com/goerz/convert_encoding.pyWorks on any platform. Download watchtower bound volumes pdf. Requires Python 2.7.
Convert Ascii To Text Online
My favorite tool for this is Jedit (a java based text editor) which has two very convenient features :
- One which enables the user to reload a text with a different encoding (and, as such, to control visually the result)
- Another one which enables the user to explicitly choose the encoding (and end of line char) before saving
Simply change encoding of loaded file in IntelliJ IDEA IDE, on the right of status bar (bottom), where current charset is indicated. It prompts to Reload or Convert, use Convert. Make sure you backed up original file in advance.
As described on How do I correct the character encoding of a file?Synalyze It! lets you easily convert on OS X between all encodings supported by the ICU library.
Additionally you can display some bytes of a file translated to Unicode from all the encodings to see quickly which is the right one for your file.
protected by chownSep 28 '12 at 23:21
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?