Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > utility to convert from ansi to unicode

Reply
Thread Tools

utility to convert from ansi to unicode

 
 
emagzz
Guest
Posts: n/a
 
      11-22-2006
Hi all,

I need to convert many text file from ANSI to UNICODE.
Some body knows if there is a free utility that can do this from the
command line
so as I can use it inside a batch file.

Thank you
Emanuele

 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      11-22-2006
emagzz wrote:
>
> I need to convert many text file from ANSI to UNICODE.
> Some body knows if there is a free utility that can do this from the
> command line
> so as I can use it inside a batch file.


short int widechar;
unsigned char ch;

do {
ch = getnext();
widechar = ch;
putwide(widechar);
while (ch);

assuming (sizeof(short) > 1) and that strings are '\0' terminated.
No worries about endianess with the above. Depends on the known
range of ANSI chars.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>


 
Reply With Quote
 
 
 
 
Jens Thoms Toerring
Guest
Posts: n/a
 
      11-22-2006
emagzz <(E-Mail Removed)> wrote:
> I need to convert many text file from ANSI to UNICODE.


If the files are "clean" ANSI and you want to go to UTF-8 no
conversion is needed.

> Some body knows if there is a free utility that can do this from the
> command line so as I can use it inside a batch file.


What makes you think that a newsgroup about the C programming
laguage would be a good place to ask this?

<off topic>
See e.g. http://www.gnu.org/software/recode/recode.html
</off topic>
Regards, Jens
--
\ Jens Thoms Toerring ___ http://www.velocityreviews.com/forums/(E-Mail Removed)
\__________________________ http://toerring.de
 
Reply With Quote
 
Leslie Kis-Adam
Guest
Posts: n/a
 
      11-22-2006
emagzz wrote:
> Hi all,
>
> I need to convert many text file from ANSI to UNICODE.
> Some body knows if there is a free utility that can do this from the
> command line
> so as I can use it inside a batch file.
>
> Thank you
> Emanuele
>


Umm. I think it's a little bit off-topic. 8-|

Laszlo Kis-Adam
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      11-22-2006
"emagzz" <(E-Mail Removed)> writes:
> I need to convert many text file from ANSI to UNICODE.
> Some body knows if there is a free utility that can do this from the
> command line
> so as I can use it inside a batch file.


What do you mean by ANSI? (That's the name of the US standards body;
there are a plethora of ANSi standards.)

If you mean ASCII, that's a 7-bit code. There are several encodings
of Unicode. And I don't think this is the right newsgroup for your
question anyway; I'm not entirely sure what is. Perhaps
comp.programming?

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      11-22-2006
CBFalconer <(E-Mail Removed)> writes:
> emagzz wrote:
>>
>> I need to convert many text file from ANSI to UNICODE.
>> Some body knows if there is a free utility that can do this from the
>> command line
>> so as I can use it inside a batch file.

>
> short int widechar;
> unsigned char ch;
>
> do {
> ch = getnext();
> widechar = ch;
> putwide(widechar);
> while (ch);
>
> assuming (sizeof(short) > 1) and that strings are '\0' terminated.
> No worries about endianess with the above. Depends on the known
> range of ANSI chars.


What the heck is "putwide"? There's no such function in standard C.
In fact, there appears to be no such function at all. A Google search
turned up just one hit, and that appears to be the result of some
blanks being left out of an old index on docs.sun.com.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      11-22-2006
In article <(E-Mail Removed)>,
Keith Thompson <(E-Mail Removed)> wrote:

>> I need to convert many text file from ANSI to UNICODE.


>What do you mean by ANSI? (That's the name of the US standards body;
>there are a plethora of ANSi standards.)


He probably means the Windows 1252 encoding, commonly known
(apparently) as "ANSI"[*]. It's the same as ISO Latin-1, but with a
random bunch of printable characters instead of the C1 controls. If
it was Latin-1, the conversion to Unicode would be trivial, since the
code points are the same, but it isn't, so it isn't.
[*] I think it stands for "A Non-Standard Incoding".

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      11-22-2006
Keith Thompson wrote:
> CBFalconer <(E-Mail Removed)> writes:
>> emagzz wrote:
>>>
>>> I need to convert many text file from ANSI to UNICODE.
>>> Some body knows if there is a free utility that can do this from
>>> the command line so as I can use it inside a batch file.

>>
>> short int widechar;
>> unsigned char ch;
>>
>> do {
>> ch = getnext();
>> widechar = ch;
>> putwide(widechar);
>> while (ch);
>>
>> assuming (sizeof(short) > 1) and that strings are '\0' terminated.
>> No worries about endianess with the above. Depends on the known
>> range of ANSI chars.

>
> What the heck is "putwide"? There's no such function in standard C.
> In fact, there appears to be no such function at all. A Google search
> turned up just one hit, and that appears to be the result of some
> blanks being left out of an old index on docs.sun.com.


getnext and putwide are shorthand for whatever the OP wants to do
to get the input and dump the output. I thought it was obvious.
Guess not.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

 
Reply With Quote
 
Kenny McCormack
Guest
Posts: n/a
 
      11-23-2006
In article <(E-Mail Removed)>,
CBFalconer <(E-Mail Removed)> wrote:
....
>getnext and putwide are shorthand for whatever the OP wants to do
>to get the input and dump the output. I thought it was obvious.
>Guess not.


*Nothing* is obvious to KT. The guy is dumber than three bags of
hammers.

 
Reply With Quote
 
Nelu
Guest
Posts: n/a
 
      11-23-2006
emagzz wrote:
> Hi all,
>
> I need to convert many text file from ANSI to UNICODE.
> Some body knows if there is a free utility that can do this from the
> command line
> so as I can use it inside a batch file.


This is off-topic here.

On my Linux system there's a utility called uniconv. *man
unicode* will tell you what it does. You can either ask in a
unicode group if there is one or a Linux/UNIX group. I don't know
if the utility exists for other environments and I have no idea
how it works. I heard about it when I was switching gentoo to UTF-8.

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Convert unicode escape sequences to unicode in a file Jeremy Python 0 01-11-2011 11:39 PM
Convert unicode escape sequences to unicode in a file Jeremy Python 1 01-11-2011 10:36 PM
pre-ansi to ansi c++ conversion? Frank Iannarilli C++ 2 07-21-2009 11:05 PM
Are there statistics packages in ANSI C and/or ANSI C++? lbrtchx@gmail.com C Programming 11 04-28-2008 03:00 AM
Are there statistics packages in ANSI C and/or ANSI C++? lbrtchx@gmail.com C++ 1 04-24-2008 06:44 PM



Advertisments