473,385 Members | 1,570 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,385 software developers and data experts.

The C execution character set

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This question pertains to both Standard C and platform-dependent
features, hence the crosspost.

I'm trying to understand exactly how the "execution character set"
works. On GNU/Linux, using GCC >= 3.4, if I compile a C source file
(any encoding), by default the execution character set is UTF-8, and
the wide execution character set is UTF-32.

What I want to understand is what the implications of this are on the
various operations I might want to perform on any of the strings. As
an example:

#include <locale.h>
#include <stdio.h>
#include <wchar.h>

int
main (void)
{
setlocale (LC_ALL, "");
printf("‘Name1’\n");
printf("%ls\n", L"‘Name2’");
fwide(stderr, 1);
fwprintf(stderr, L"‘Name3’\n");
fwprintf(stderr, L"%s\n", "‘Name4’");
printf("‘Name5’\n");
return 0;
}

If I run in a normal (UTF-8) locale:

$ ./test
‘Name1’
‘Name2’
‘Name3’
‘Name4’
‘Name5’

Now, running in a C locale:

$ ./test
'Name3'
‘Name1’
‘Name5’

"‘Name1’" and "‘Name5’" are the same. These passed through
byte-for-byte identical. No conversions took place, I think.

"‘Name1’" (wide→narrow) was lost. Why?
"‘Name4’" (narrow→wide) was lost. Why?

"‘Name3’" (wide→wide) was *not* lost. Moreover, it was
transliterated (UTF-32->US-ASCII) into a readable form for the locale.
Where does the conversion take place, and how does the C runtime know
what the source and destination charset are? I can't replicate the
conversion with iconv(), so I'd like to know how to do it by hand.

I'd like to understand the reasons for why each of these cases work
the way they do.
Thanks,
Roger

- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFCuzQ4VcFcaSW/uEgRApOUAJ49ghx4LxRo8Tn0RdOafRjdACDBqQCfQOA7
KLhWn0VmNzDLFD8gPHBFpgU=
=rX99
-----END PGP SIGNATURE-----
Nov 15 '05 #1
0 1272

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

Similar topics

3
by: curi42 | last post by:
I am running two functions in a row that do the same thing. One runs in .14 seconds, the other 56. I'm confused. I wrote another version of the program and couldn't get the slow behavior again,...
5
by: James | last post by:
I'm totally new to C++ and when I try to execute the simple program I have written, it closes the console application as soon as it has finished excuting. This obviously means I cannot see the...
1
by: Bill Nedell | last post by:
I am trying to write a PL/PgSQL function that can be given a table name as an argument at execution time and I don't see any way of doing it. I want the user to be able to specify the table...
1
by: Chris LaJoie | last post by:
Hi, I have an app that runs many simultaneous threads. I have noticed (took me a while to figure out what it was doing though) that sometimes if there is a problem, the thread will simply...
2
by: Ina Schmitz | last post by:
Hi NG, does IBM Universal Database 8.2 make any difference between actual and estimated execution plans like in SQL Server ("set showplan_all on" for estimated execution plan and "set statistics...
12
by: Joachim Pense | last post by:
Is there recommended way to get the execution plan for queries involving global temporary tables (from the UNIX command line or within a script)? I run the queries in Perl scripts, and the only...
40
by: kavi | last post by:
Hello friends, Could any one tell the way of calculating the speed of c program execution?
4
by: reva | last post by:
hi all , I have used switch case to check whether a particular character is present in another array of characters. i want the code to do if the particular character is found then paint function is...
2
by: npcarp | last post by:
Is this hard? I am introducing Python to my students and want to make a simple, interactive program that will, while it's running, 'listen' for any keyboard events. That is, I don't want to...
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:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.