Sponsored Content
Top Forums Shell Programming and Scripting Trying to convert utf-8 to WINDOWS-1251 Post 302908050 by umen on Thursday 3rd of July 2014 07:36:35 AM
Old 07-03-2014
Trying to convert utf-8 to WINDOWS-1251

Hello all
i have utf-8 file that i try to convert to WINDOWS-1251 on linux
without any success
the file name is utf-8 when i try to do :
Code:
file -bi test.txt

it gives me :
Code:
text/plain; charset=utf-8

when i try to convert the file i do :
Code:
/usr/bin/iconv -f UTF-8 -t WINDOWS-1251 test.txt > test2.txt

it gives me :
Code:
/usr/bin/iconv: illegal input sequence at position 0

where the first string in the file is :
Code:
1CClient

what im doing wrong here ?
 

10 More Discussions You Might Find Interesting

1. Programming

Howto convert Ascii -> UTF-8 & back C++

While working with russian text under FreeBSD&MySQL I need to convert a string from MySQL to the Unicode format. I've just started my way in C++ under FreeBSD , so please explain me how can I get ascii code of Char variable and also how can i get a character into variable with the specified ascii... (3 Replies)
Discussion started by: macron
3 Replies

2. Solaris

convert windows OS as Solaris remotely

I have a Windows 2000 Terminal, which I want to convert into Solaris 10. I am connected to windows terminal remotely via iLO and then inserted the solaris DVD in my local drive. Now when I connect to Windows machine from 'RDP' - I can see local DVD in there - and IF I then reboot remote machine... (1 Reply)
Discussion started by: panchpan
1 Replies

3. UNIX for Advanced & Expert Users

Convert UTF-8 encoded hex value to a character

Hi, I have a non-ascii character (Ŵ), which can be represented in UTF-8 encoding as equivalent hex value (\xC5B4). Is there a function in unix to convert this hex value back to display the charcter ? (10 Replies)
Discussion started by: sumirmehta
10 Replies

4. Solaris

MySQL Authentication errror 1251 on Solaris.

I am trying to connect to MySQL installed on windows from Solaris machine. While doing this getting error as: "Client does not support authentication protocol requested by server; consider upgrading MySQL client; errno = 1251" I have installed mysql-5.1.34-solaris10-sparc.tar.gz on... (1 Reply)
Discussion started by: amit_27
1 Replies

5. Shell Programming and Scripting

Convert Windows Metacharacters to Regular Text

Hi, all. I have a need to take a flat file FTP'd from Windows to Unix and convert it for loading into a MySQL database without manual intervention. However, some characters are "fancified" (e.g. the fancy Beginning and End double-quotes from Windows) that show up as codes using vi. I need to... (4 Replies)
Discussion started by: superdelic
4 Replies

6. Red Hat

Can't convert 7bit ASCII to UTF-8

Hello, I am trying to convert a 7bit ASCII file to UTF-8. I have used iconv before though it can't recognize it for some reason and says unknown file encoding. When I used ascii2uni package with different package, ./ascii2uni -a K -a I -a J -a X test_file > new_test_file It still... (2 Replies)
Discussion started by: rockf1bull
2 Replies

7. Shell Programming and Scripting

Convert this Windows script so I can use it on Macbook

Hi guys, I am been banging my head for days on something that appears too simple to be so hard for me. I have this bash script which I used just fine on my windows PC. I took this file over to my Macbook and try to run it and it fails like no tomorrow. This is the contents of the file:... (3 Replies)
Discussion started by: richsark
3 Replies

8. Linux

Help to Convert file from UNIX UTF-8 to Windows UTF-16

Hi, I have tried to convert a UTF-8 file to windows UTF-16 format file as below from unix machine unix2dos < testing.txt | iconv -f UTF-8 -t UTF-16 > out.txt and i am getting some chinese characters as below which l opened the converted file on windows machine. LANG=en_US.UTF-8... (3 Replies)
Discussion started by: phanidhar6039
3 Replies

9. Shell Programming and Scripting

Convert UTF-8 file to ASCII/ISO8859-1 OR replace characters

I am trying to develop a script which will work on a source UTF-8 file and perform one or more of the following It will accept the target encoding as an argument e.g. US-ASCII or ISO-8859-1, etc 1. It should replace all occurrences of characters outside target character set by " " (space) or... (3 Replies)
Discussion started by: hemkiran.s
3 Replies

10. UNIX for Beginners Questions & Answers

Convert files to UTF-8 on AIX 7.1

Dears, I have a shell script - working perfectly on Oracle Linux - that detects the encoding (the charset to be exact) of the files in a specified directory using the "file" command (The file command outputs the charset in Linux, but doesn't do that in AIX), then if the file isn't a UTF-8 text... (4 Replies)
Discussion started by: JeanM-1
4 Replies
PRECONV(1)						      General Commands Manual							PRECONV(1)

NAME
preconv - convert encoding of input files to something GNU troff understands SYNOPSIS
preconv [-dr] [-e encoding] [files ...] preconv -h | --help preconv -v | --version It is possible to have whitespace between the -e command line option and its parameter. DESCRIPTION
preconv reads files and converts its encoding(s) to a form GNU troff(1) can process, sending the data to standard output. Currently, this means ASCII characters and `[uXXXX]' entities, where `XXXX' is a hexadecimal number with four to six digits, representing a Unicode input code. Normally, preconv should be invoked with the -k and -K options of groff. OPTIONS
-d Emit debugging messages to standard error (mainly the used encoding). -Dencoding Specify default encoding if everything fails (see below). -eencoding Specify input encoding explicitly, overriding all other methods. This corresponds to groff's -Kencoding option. Without this switch, preconv uses the algorithm described below to select the input encoding. --help -h Print help message. -r Do not add .lf requests. --version -v Print version number. USAGE
preconv tries to find the input encoding with the following algorithm. 1. If the input encoding has been explicitly specified with option -e, use it. 2. Otherwise, check whether the input starts with a Byte Order Mark (BOM, see below). If found, use it. 3. Finally, check whether there is a known coding tag (see below) in either the first or second input line. If found, use it. 4. If everything fails, use a default encoding as given with option -D, by the current locale, or `latin1' if the locale is set to `C', `POSIX', or empty (in that order). Note that the groff program supports a GROFF_ENCODING environment variable which is eventually expanded to option -k. Byte Order Mark The Unicode Standard defines character U+FEFF as the Byte Order Mark (BOM). On the other hand, value U+FFFE is guaranteed not be a Unicode character at all. This allows to detect the byte order within the data stream (either big-endian or lower-endian), and the MIME encodings `UTF-16' and `UTF-32' mandate that the data stream starts with U+FEFF. Similarly, the data stream encoded as `UTF-8' might start with a BOM (to ease the conversion from and to UTF-16 and UTF-32). In all cases, the byte order mark is not part of the data but part of the encoding protocol; in other words, preconv's output doesn't contain it. Note that U+FEFF not at the start of the input data actually is emitted; it has then the meaning of a `zero width no-break space' character - something not needed normally in groff. Coding Tags Editors which support more than a single character encoding need tags within the input files to mark the file's encoding. While it is pos- sible to guess the right input encoding with the help of heuristic algorithms for data which represents a greater amount of a natural lan- guage, it is still just a guess. Additionally, all algorithms fail easily for input which is either too short or doesn't represent a natu- ral language. For these reasons, preconv supports the coding tag convention (with some restrictions) as used by GNU Emacs and XEmacs (and probably other programs too). Coding tags in GNU Emacs and XEmacs are stored in so-called File Variables. preconv recognizes the following syntax form which must be put into a troff comment in the first or second line. -*- tag1: value1; tag2: value2; ... -*- The only relevant tag for preconv is `coding' which can take the values listed below. Here an example line which tells Emacs to edit a file in troff mode, and to use latin2 as its encoding. ." -*- mode: troff; coding: latin-2 -*- The following list gives all MIME coding tags (either lowercase or uppercase) supported by preconv; this list is hard-coded in the source. big5, cp1047, euc-jp, euc-kr, gb2312, iso-8859-1, iso-8859-2, iso-8859-5, iso-8859-7, iso-8859-9, iso-8859-13, iso-8859-15, koi8-r, us-ascii, utf-8, utf-16, utf-16be, utf-16le In addition, the following hard-coded list of other tags is recognized which eventually map to values from the list above. ascii, chinese-big5, chinese-euc, chinese-iso-8bit, cn-big5, cn-gb, cn-gb-2312, cp878, csascii, csisolatin1, cyrillic-iso-8bit, cyrillic-koi8, euc-china, euc-cn, euc-japan, euc-japan-1990, euc-korea, greek-iso-8bit, iso-10646/utf8, iso-10646/utf-8, iso-latin-1, iso-latin-2, iso-latin-5, iso-latin-7, iso-latin-9, japanese-euc, japanese-iso-8bit, jis8, koi8, korean-euc, korean-iso-8bit, latin-0, latin1, latin-1, latin-2, latin-5, latin-7, latin-9, mule-utf-8, mule-utf-16, mule-utf-16be, mule-utf-16-be, mule-utf-16be-with-signature, mule-utf-16le, mule-utf-16-le, mule-utf-16le-with-signature, utf8, utf-16-be, utf-16-be-with-signature, utf-16be-with-signature, utf-16-le, utf-16-le-with-signature, utf-16le-with-signature Those tags are taken from GNU Emacs and XEmacs, together with some aliases. Trailing `-dos', `-unix', and `-mac' suffixes of coding tags (which give the end-of-line convention used in the file) are stripped off before the comparison with the above tags happens. Iconv Issues preconv by itself only supports three encodings: latin-1, cp1047, and UTF-8; all other encodings are passed to the iconv library functions. At compile time it is searched and checked for a valid iconv implementation; a call to `preconv --version' shows whether iconv is used. BUGS
preconv doesn't support local variable lists yet. This is a different syntax form to specify local variables at the end of a file. SEE ALSO
groff(1) the GNU Emacs and XEmacs info pages Groff Version 1.21 31 December 2010 PRECONV(1)
All times are GMT -4. The time now is 05:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy