473,378 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Wide Characters and tchar

Hi
Can someone pls explain the usage of wide characters and tchar?
Also, what should I be careful about, while coding in C, to make my
code portable and suitable for internationalization?
( I am looking for some tips from experienced programmers)
Thanks
Anitha

Nov 14 '05 #1
1 2452
Anitha Adusumilli wrote:
Can someone pls explain the usage of wide characters and tchar?
Also, what should I be careful about, while coding in C, to make my
code portable and suitable for internationalization?
( I am looking for some tips from experienced programmers)


In ISO C, the portable type for wide characters is actually wchar_t, and
wide character strings are null-terminated arrays of these. It also
provides a bunch of wide-character versions of ordinary C functions -
you get them by adding "w" at various random locations or by changing
"a" or "str" to "wcs":

printf -> wprintf
scanf -> wscanf
sprintf -> swprintf
fgetc -> fgetwc
strcpy -> wcscpy
atof -> wcstof

Search for some of these to see more. There are also handy conversion
functions for going between different types of characters and strings,
such as btowc, wctob, mbrtowc, wcrtomb, mbsrtowcs, wcsrtombs.

Be careful, though: there are at least three different kinds of wide
characters in Windows, not necessarily the same, and each with their own
API. Many API functions have versions for each kind. Pick one and stick
with it. If your program might conceivably be ported in the future,
wchar_t is usually your best bet.

As for other internationalization tips, the obvious things are to keep
any kind of text out of your code and in some centralized place and to
not write code that depends upon properties of one language (such as
grammar logic or even left-to-right rendering). There are some good web
sites and books on the topic. Others might have more to say.
--
Derrick Coetzee
I grant this newsgroup posting into the public domain. I disclaim all
express or implied warranty and all liability. I am not a professional.
Nov 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jonathan Mcdougall | last post by:
I started using boost's filesystem library a couple of days ago. In its FAQ, it states "Wide-character names would provide an illusion of portability where portability does not in fact exist....
15
by: Steve | last post by:
Hi, I've been charged with investigating the possibilities of internationalizing our C++ libraries. std::strings are used all over the place, and unfortunately a mixture of...
3
by: yazan jab | last post by:
Is it true that Multibyte characters are : char arrays (witch represent a string from the basic characters set). In this case Wide characters are the way for encoding characters from the...
1
by: jjf | last post by:
Do Standard C's wide characters and wide strings require absolutely that each character be stored in a single wchar_t, or can characters be "multi-wchar_t" in the same way that they can be...
2
by: Mick_fae_Glesga | last post by:
Hello everyone! OK, I'm writing a windows program that requires the user to enter Cyrillic characters into an Edit control. But, I can't seem to get the Cyrillic characters to appear in the...
8
by: Brand Bogard | last post by:
Does the C standard include a library function to convert an 8 bit character string to a 16 bit character string?
4
by: thinktwice | last post by:
i'm using VC++6 IDE i know i could use macros like A2T, T2A, but is there any way more decent way to do this?
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
1
by: asiru | last post by:
My mission is to print Unicode characters using this program.I have been on this for several months. I follow the following procedure to enable unicode; 1.File > New> Project>win 32 console...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.