PDA

View Full Version : Unicode/ASCII



Ruski
10-03-2002, 11:44 AM
I've just read a part of this tutorial: http://sunlightd.virtualave.net/Windows/GUI/Intro.html but I can't understand what is that _T for.. Is it necessary NOW?
It says it's Unicode.. is it true that it's better than ASCII? Most of the programs use ASCII now..

btq
10-03-2002, 12:17 PM
unicode is for multilingual purposes, ie, every character has it's own value and it's supposed to be the new standard..

_T() just formats hte ASCII string into a unicode string...
ie, _T("hello") is a unicode string that reads "hello"...

hope this is an answer?
/btq :)

Davros
10-03-2002, 12:48 PM
The results of a poll will surely depend on who you ask:

Ask 100 ignorant English speakers, like me, and we'll all vote for ASCII. (Why can't the whole world just use English! :)

Ask 100 chinese programmers and I'm sure the answer would be different.

Ruski
10-04-2002, 08:48 AM
Well.. but I've never seen anybody in tutorials & stuff using _T("Hello"); .. that's confusing.. why not just "Hello" ?? :(

Ruski
10-04-2002, 08:49 AM
Hey! By the way.. where can I get a resource editor (not vc++ ... preferably a plugin for dev-C++ 5b)

Stoned_Coder
10-04-2002, 09:02 AM
If you write programs for windows you should be aware of unicode.
Windows 95,98 and me all run on ascii
windows 2000 family runs on unicode.

The _T macro will compile your strings as ascii if _UNICODE is not defined. If it is then _T macro will compile your strings as unicode.
Petzold in his book Programming windows devotes a whole chapter to this as he feels it is so important. You will get a far better explanation of this by reading that chapter than i can give you here.

Eibro
10-04-2002, 09:07 AM
Whether you use it or not... the Windows NT platforms (NT/2K/XP) convert your ASCII strings into unicode strings for internal use anyway. This will give you a performance hit, so why not just start with Unicode in the first place?

kermi3
10-04-2002, 09:24 AM
This is really a General Discussions thread. Therefore it has been moved there....

Kermi3

Ruski
10-04-2002, 09:30 AM
If I work with Unicode.. will it work in 9x ?

ygfperson
10-04-2002, 01:00 PM
it depends on the application... probably.

Ruski
10-04-2002, 01:09 PM
Application??

Driveway
10-04-2002, 01:17 PM
program
executable
...

Eibro
10-04-2002, 01:28 PM
In short
NO!
That's why you use generic functions like _tcslen(), TEXT("hello") and generic types like TCHAR which will compile to either Unicode or ASCII depending on whether UNICODE is #defined. Windows9x does not support Unicode. Windows NT/2K/XP supports both to some extent, and Windows CE only supports Unicode.

Ruski
10-04-2002, 01:45 PM
But why isn't ASCII working on NT/2k/XP ??

RoD
10-04-2002, 01:59 PM
>But why isn't ASCII working on NT/2k/XP ??

it does work , thats what i currently program in and i'm on xp.


So, is that why, in .NET, it has a _T main or whatever instead of a blank project? to encourage unicode? I am a newbie so i could go either way, i think it might just be more confusing not to go with ASCII.

Ruski
10-04-2002, 02:07 PM
Yea.. me2.. im gonna stay with ASCII :p

Eibro
10-04-2002, 02:18 PM
You're not staying with ASCII, your strings are being converted to unicode internally by the OS. This is overhead, this degrades performance. If you're on and NT based Operating System, you need to use Unicode!

RoD
10-04-2002, 03:26 PM
If its better then i will learn to use it. Is there a way to take code you already have and convert it outside of the compiler? Probably not but more then 90% of the tutorials i have seen don't go by uni.

salvelinus
10-04-2002, 03:29 PM
Unless you're writing code using the int values of chars, or need other characters for something, and you're coding in English, does it matter? Maybe there's a hit on NTFS, but is it big enough to worry about? I don't know, but this would be a minor consideration to me, since I'm not coding in chinese or urdu.
We have a couple Russian programmers at work and they have keyboards with equivalent Russian symbols underneath the standard US keyboard symbols.

Ruski
10-04-2002, 11:55 PM
Originally posted by Eibro
You're not staying with ASCII, your strings are being converted to unicode internally by the OS. This is overhead, this degrades performance. If you're on and NT based Operating System, you need to use Unicode!

I just did a little program using ASCII and ran it on Win2k, everything was fine... :p

Shade
10-05-2002, 02:30 AM
Originally posted by Ruski
I just did a little program using ASCII and ran it on Win2k, everything was fine... :p

Of course it was fine!

But win2k converted your ASCII chars into UNICODE chars.


UNICODE is the future. If you write professional software, you have no choice. If you are just a hobby programmer, you can still use ASCII (and let the OS do the converting-stuff).

But it is a minor performance benefit to use UNICODE. SO why not using it?? There are generic types and functions so you just compile the program twice - once with UNICODE disabled (for older windows systems) and once with UNICODE enabled (for newer systems).

Read the UNICODE chapter of Petzold - it will give you all information you need!

Ruski
10-05-2002, 05:24 AM
But if ASCII is converted on win2k & xp.. why not use ASCII?

Fordy
10-05-2002, 05:34 AM
>>But if ASCII is converted on win2k & xp.. why not use ASCII?

:: Clenches fist...grits teeth ::

Try reading what's above....

Win95/98/ME use ASCII....ok...

Win NT/2k/XP still allow the use of ASCII (to ensure compatibilty), but they then convert each char into a UNICODE WCHAR (wide char - 16 bit word) for their inner workings....so when you use ASCII on these platforms, there's a little bit of overhead for the conversion....

You can use a UNICODE build of your app on a Win NT/2k/XP to get rid of that overhead, but then they wont work very well on 95/98/ME as they expect ASCII......

Ken Fitlike
10-05-2002, 05:39 AM
And if you use any of the ANSI systems you may want to take a look at the microsoft layer for UNICODE, which permits (allegedly) you to compile UNICODE apps for win9x etc systems; presumably because the 'layer' does an internal conversion to ANSI.

As an example of getting used to UNICODE consider gdiplus, the apparent replacement for gdi. It comes as standard with winxp and can be downloaded from ms for win9x/2k. It uses UNICODE exclusively so if you want to use it with win9x you have to do a lot of fiddling around to convert ANSI to UNICODE strings.

Ruski
10-06-2002, 01:37 AM
What's GDI?