Thread: Re: [Dev-C++] Using Unicode in Dev-C++
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Duong Ha N. <nha...@gm...> - 2007-04-26 11:28:07
|
SGkgQWRyaWFuLCB0aGFuayB5b3UgZm9yIGFuc3dlcmluZyBteSBxdWVzdGlvbiEKCkkgdW5kZXJz dGFuZCB5b3VyIGFuc3dlci4gSSB0cmllZCB0byBkbyBhcyB5b3Ugc2FpZCBidXQgSSBkb24ndCBr bm93IGhvdyB0bwp0eXBlIFVuaWNvZGUgY2hhcmFjdGVycyBpbiBEZXYtQysrIElERS4gV2hlbiBJ IHR5cGVkICLGsCIsIGl0IGRpc3BsYXllZCAiPyIuCkNhbiB5b3UgdGVsbCBtZSBob3cgdG8gc29s dmUgaXQ/CgpJIHRyaWVkIHRvIGNvbnZlcnQgVW5pY29kZSBjaGFyYWN0ZXJzIHRvIEFOU0kgdXNp bmcgbmF0aXZlMmFzY2lpLmV4ZSAoYXMgSQpzYWlkIGF0IG15IGZpcnN0IG1haWwpIGJ1dCB0aGUg ZGlzcGxheWVkIGNoYXJhY3RlcnMgd2VyZSBub3Qgd2hhdCBJIHdhbnRlZC4KSSB0aGluayBtYXli ZSB0aGVyZSB3YXMgc29tZSBwcm9ibGVtcyB3aXRoIHRoZSBmb250cy4gQ2FuIHlvdSB0ZWxsIG1l IGhvdyB0bwpzb2x2ZSBpdD8KClRoYW5rcyBpbiBhZHZhbmNlLAoKMjAwNy80LzI1LCBhZHJpYW4g PGFkcmlhbkBsYW1pbmFyLnJ1PjoKPgo+IEhhdmUgYSBuaWNlIGRheSwgbmhhLmR1b25nQGdtYWls LmNvbSEKPiBZb3UsICJEdW9uZyBIYSBOZ3V5ZW4iIDxtYWlsdG86bmhhLmR1b25nQGdtYWlsLmNv bT4gd3JvdGU6Cj4KPgo+ID5IZWxsbyBldmVyeW9uZSwKPiA+SSdtIHVzaW5nIERldi1DKysgNC45 LjkuMiB0byB3cml0ZSBXaW5kb3dzIGFwcGxpY2F0a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IFRDSEFSLAo+IGVsc2UKPiB0eXBlZGVmIGNoYXIgVENIQVI7IGFsc28gZGVm aW5lZCBmdW5jdGlvbnMsIHdvcmtpbmcgd2l0aCB0aGlzIHR5cGUgKGZvcgo+IG1vcmUgc2VlIE1T RE4gYW5kIHRjaGFyLmggZmlsZSkKPgo+Cj4gU2luY2VyZWx5LCBDaHVyaW4uCj4KPiBQLlMuIEV4 Y3VzZSBtZSBmb3IgbXkgYmFkIGVuZ2xpc2ggLSBpdCdzIG5vdCBteSBuYXRpdmUgbGFuZ3VhZ2Uu Cj4KPgo+Cg== |
|
From: Per W. <pw...@ia...> - 2007-04-26 13:00:26
|
There are windows API calls to convert between Unicode and MBCS (MultiByte
Character Set).
You can _never_ convert unicode to ANSI (other than for the characters
that fit in the ANSI character set).
You want to use a Unicode-compatible editor, i.e. an editor that checks if
there are a magic marker in the beginning of the file to inform that the
file is not ASCII (or ANSI or whatever single-byte format) but either UTF8
or UTF16.
/pwm
On Thu, 26 Apr 2007, Duong Ha Nguyen wrote:
> Hi Adrian, thank you for answering my question!
>
> I understand your answer. I tried to do as you said but I don't know how =
to
> type Unicode characters in Dev-C++ IDE. When I typed "=C6=B0", it display=
ed "?".
> Can you tell me how to solve it?
>
> I tried to convert Unicode characters to ANSI using native2ascii.exe (as =
I
> said at my first mail) but the displayed characters were not what I wante=
d.
> I think maybe there was some problems with the fonts. Can you tell me how=
to
> solve it?
>
> Thanks in advance,
>
> 2007/4/25, adrian <ad...@la...>:
> >
> > Have a nice day, nha...@gm...!
> > You, "Duong Ha Nguyen" <mailto:nha...@gm...> wrote:
> >
> >
> > >Hello everyone,
> > >I'm using Dev-C++ 4.9.9.2 to write Windows application. I would like t=
o
> > >write program using Unicode encoding. I tried to use native2ascii to
> > >translate Unicode source code to ANSI, but it didn't display exactly w=
hat
> > I
> > >want. Can someone tell me how to write Windows programs with Unicode i=
n
> > >Dev-C++?
> > >Thanks in advance.
> > >
> > >
> > WinAPI has a two function for straight working with Unicode strings:
> > - MultiByteToWideChar(...) - for encoding ANSI strings in Unicode, and
> > - WideCharToMultiByte(...) - for decoding Unicode to ANSI
> >
> > Also you can use TCHAR type for unvisible translating, for example:
> >
> > #include <windows.h>
> > #include <stdio.h>
> > #ifndef UNICODE
> > #define UNICODE
> > ...
> > TCHAR *s;
> > scanf ("%s", s);
> > printf("%s\n", s);
> > ...
> > #endif //UNICODE
> >
> > if you define UNICODE then
> > typedef wchar_t TCHAR,
> > else
> > typedef char TCHAR; also defined functions, working with this type (for
> > more see MSDN and tchar.h file)
> >
> >
> > Sincerely, Churin.
> >
> > P.S. Excuse me for my bad english - it's not my native language.
> >
> >
> >
>
|
|
From: Thymian <Th...@gm...> - 2007-04-26 15:00:51
|
Additional to the answer of Per Westermark you could take a look to this Wikipedia article for a better / deeper understanding of the coherences of UTF along with operating systems, editors, e-mails, web, fonts, storage, converters and ... a lot more: http://en.wikipedia.org/wiki/Unicode Gruß, Werner Kitzmann Duong Ha Nguyen schrieb: > Hi Adrian, thank you for answering my question! > > I understand your answer. I tried to do as you said but I don't know > how to type Unicode characters in Dev-C++ IDE. When I typed "ư", it > displayed "?". Can you tell me how to solve it? > > I tried to convert Unicode characters to ANSI using native2ascii.exe > (as I said at my first mail) but the displayed characters were not > what I wanted. I think maybe there was some problems with the fonts. > Can you tell me how to solve it? > > Thanks in advance, > > 2007/4/25, adrian <ad...@la... <mailto:ad...@la...>>: > > Have a nice day, nha...@gm... <mailto:nha...@gm...>! > You, "Duong Ha Nguyen" <mailto:nha...@gm... > <mailto:nha...@gm...>> wrote: > > > >Hello everyone, > >I'm using Dev-C++ 4.9.9.2 <http://4.9.9.2> to write Windows > application. I would like to > >write program using Unicode encoding. I tried to use native2ascii to > >translate Unicode source code to ANSI, but it didn't display > exactly what I > >want. Can someone tell me how to write Windows programs with > Unicode in > >Dev-C++? > >Thanks in advance. > > > > > WinAPI has a two function for straight working with Unicode strings: > - MultiByteToWideChar(...) - for encoding ANSI strings in Unicode, > and > - WideCharToMultiByte(...) - for decoding Unicode to ANSI > > Also you can use TCHAR type for unvisible translating, for example: > > #include <windows.h> > #include <stdio.h> > #ifndef UNICODE > #define UNICODE > ... > TCHAR *s; > scanf ("%s", s); > printf("%s\n", s); > ... > #endif //UNICODE > > if you define UNICODE then > typedef wchar_t TCHAR, > else > typedef char TCHAR; also defined functions, working with this type > (for more see MSDN and tchar.h file) > > > Sincerely, Churin. > > P.S. Excuse me for my bad english - it's not my native language. > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ------------------------------------------------------------------------ > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Jan M. <jan...@vo...> - 2007-05-02 09:08:18
|
Hello,
I would like to ask if there is a way to find out which code page
iscurrently set for Command Prompt in Windows (I use XP Prof).
I have tried to use somthing like
...
cp = system("chcp");
printf ("%d", cp);
But there is always 0 in return value cp.
The return values should be an implementation defined. So are they
implemtented in Windows? Did I a mistake?
Thank you.
Jan Mura
jan...@vo...
|
|
From: Per W. <pw...@ia...> - 2007-05-02 09:29:46
|
First of all system("") basically starts a new console for running the
command. I'm not sure if you can guarantee that the new environment
inherrits every characteristic from your application.
Second - the cp variable is not the answer for the chcp command. It is the
return value. In this case, a value of 0 means that the command executed
ok. It corresponds to the value you send to the function exit(), or the
return value when you leave the main() function.
When you use system() to run a command, that command will emit it's
answers to stdout - i.e. it will print the information. Not return it as
a value for system() to return.
Go to the Microsoft MSDN web site. They have a complete reference of the
Win32 API. There, you can find a huge amount of functions that you can
call directly from your code. Real functions, producing real answers.
There, you have a lot of information about current locale, code pages etc.
/pwm
On Wed, 2 May 2007, Jan Mura wrote:
> Hello,
>
> I would like to ask if there is a way to find out which code page
> iscurrently set for Command Prompt in Windows (I use XP Prof).
>
> I have tried to use somthing like
>
> ...
> cp = system("chcp");
> printf ("%d", cp);
>
>
> But there is always 0 in return value cp.
> The return values should be an implementation defined. So are they
> implemtented in Windows? Did I a mistake?
>
> Thank you.
>
> Jan Mura
> jan...@vo...
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Jan M. <jan...@vo...> - 2007-05-02 13:36:38
|
Hello,
thank you for the hint and the explanation.=20
I will try to find something on MSDN when I will feel ready to visit the =
page:-)
Jan Mura=20
----- Original Message -----=20
From: Per Westermark=20
To: Jan Mura=20
Cc: dev...@li...=20
Sent: Wednesday, May 02, 2007 11:29 AM
Subject: Re: [Dev-C++] How to find out code page in DOS Command Prompt
First of all system("") basically starts a new console for running the
command. I'm not sure if you can guarantee that the new environment
inherrits every characteristic from your application.
Second - the cp variable is not the answer for the chcp command. It is =
the
return value. In this case, a value of 0 means that the command =
executed
ok. It corresponds to the value you send to the function exit(), or =
the
return value when you leave the main() function.
When you use system() to run a command, that command will emit it's
answers to stdout - i.e. it will print the information. Not return it =
as
a value for system() to return.
Go to the Microsoft MSDN web site. They have a complete reference of =
the
Win32 API. There, you can find a huge amount of functions that you can
call directly from your code. Real functions, producing real answers.
There, you have a lot of information about current locale, code pages =
etc.
/pwm
On Wed, 2 May 2007, Jan Mura wrote:
> Hello,
>
> I would like to ask if there is a way to find out which code page
> iscurrently set for Command Prompt in Windows (I use XP Prof).
>
> I have tried to use somthing like
>
> ...
> cp =3D system("chcp");
> printf ("%d", cp);
>
>
> But there is always 0 in return value cp.
> The return values should be an implementation defined. So are they
> implemtented in Windows? Did I a mistake?
>
> Thank you.
>
> Jan Mura
> jan...@vo...
>
>
> =
-------------------------------------------------------------------------=
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Michael S. <so...@ea...> - 2007-05-02 22:15:47
|
Per Westermark wrote:
>First of all system("") basically starts a new console for running the
>command. I'm not sure if you can guarantee that the new environment
>inherrits every characteristic from your application.
>
>Second - the cp variable is not the answer for the chcp command. It is the
>return value. In this case, a value of 0 means that the command executed
>ok. It corresponds to the value you send to the function exit(), or the
>return value when you leave the main() function.
>
>When you use system() to run a command, that command will emit it's
>answers to stdout - i.e. it will print the information. Not return it as
>a value for system() to return.
>
>Go to the Microsoft MSDN web site. They have a complete reference of the
>Win32 API. There, you can find a huge amount of functions that you can
>call directly from your code. Real functions, producing real answers.
>There, you have a lot of information about current locale, code pages etc.
>
>/pwm
>
>On Wed, 2 May 2007, Jan Mura wrote:
>
>
>
>>Hello,
>>
>>I would like to ask if there is a way to find out which code page
>>iscurrently set for Command Prompt in Windows (I use XP Prof).
>>
>>I have tried to use somthing like
>>
>>...
>>cp = system("chcp");
>>printf ("%d", cp);
>>
>>
>>But there is always 0 in return value cp.
>>The return values should be an implementation defined. So are they
>>implemtented in Windows? Did I a mistake?
>>
>>Thank you.
>>
>>Jan Mura
>>jan...@vo...
>>
>>
>>-------------------------------------------------------------------------
>>This SF.net email is sponsored by DB2 Express
>>Download DB2 Express C - the FREE version of DB2 express and take
>>control of your XML. No limits. Just data. Click to get it now.
>>http://sourceforge.net/powerbar/db2/
>>_______________________________________________
>>Dev-cpp-users mailing list
>>Dev...@li...
>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>>
>>
>>
>
>
>-------------------------------------------------------------------------
>This SF.net email is sponsored by DB2 Express
>Download DB2 Express C - the FREE version of DB2 express and take
>control of your XML. No limits. Just data. Click to get it now.
>http://sourceforge.net/powerbar/db2/
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
|
|
From: Michael S. <so...@ea...> - 2007-05-02 22:16:08
|
Per Westermark wrote:
>First of all system("") basically starts a new console for running the
>command. I'm not sure if you can guarantee that the new environment
>inherrits every characteristic from your application.
>
>Second - the cp variable is not the answer for the chcp command. It is the
>return value. In this case, a value of 0 means that the command executed
>ok. It corresponds to the value you send to the function exit(), or the
>return value when you leave the main() function.
>
>When you use system() to run a command, that command will emit it's
>answers to stdout - i.e. it will print the information. Not return it as
>a value for system() to return.
>
>Go to the Microsoft MSDN web site. They have a complete reference of the
>Win32 API. There, you can find a huge amount of functions that you can
>call directly from your code. Real functions, producing real answers.
>There, you have a lot of information about current locale, code pages etc.
>
>/pwm
>
>On Wed, 2 May 2007, Jan Mura wrote:
>
>
>
>>Hello,
>>
>>I would like to ask if there is a way to find out which code page
>>iscurrently set for Command Prompt in Windows (I use XP Prof).
>>
>>I have tried to use somthing like
>>
>>...
>>cp = system("chcp");
>>printf ("%d", cp);
>>
>>
>>But there is always 0 in return value cp.
>>The return values should be an implementation defined. So are they
>>implemtented in Windows? Did I a mistake?
>>
>>Thank you.
>>
>>Jan Mura
>>jan...@vo...
>>
>>
>>-------------------------------------------------------------------------
>>This SF.net email is sponsored by DB2 Express
>>Download DB2 Express C - the FREE version of DB2 express and take
>>control of your XML. No limits. Just data. Click to get it now.
>>http://sourceforge.net/powerbar/db2/
>>_______________________________________________
>>Dev-cpp-users mailing list
>>Dev...@li...
>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>>
>>
>>
>
>
>-------------------------------------------------------------------------
>This SF.net email is sponsored by DB2 Express
>Download DB2 Express C - the FREE version of DB2 express and take
>control of your XML. No limits. Just data. Click to get it now.
>http://sourceforge.net/powerbar/db2/
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
|