Write accents in C.

G

Gabriel Marinello

I am Latinanmerican an I would like to knonw how make accents using
printlf. Thanks.
 
G

Guest

Gabriel said:
I am Latinanmerican an I would like to knonw how make accents using
printlf. Thanks.

The "portable" (C++/C99-specified but not widely implemented in C
compilers) way is to specify the Unicode code points.

printf("%s\n", "\u00E1\u00E8\u00EF");

The more widely implemented way is to type accented characters directly
in the source code, but this will rely on your locale during
compilation matching that during editing.

printf("%s\n", "áèï");

In both cases, you can make it a bit more likely to work properly by
first calling the setlocale function, and then using a wide string for
printf:

printf("%ls %ls\n", L"\u00E1\u00E8\u00EF", L"áèï");

Of course, there are systems that simply do not support accented
characters. If you're dealing with such a system, neither way will
work, for obvious reasons.
 
F

Flash Gordon

Harald van Dijk wrote, On 17/01/07 15:29:
The "portable" (C++/C99-specified but not widely implemented in C
compilers) way is to specify the Unicode code points.

<snip>

Where does the C99 standard require implementations to use Unicode? It
*might* make it an explicit option but I would be very surprised if it
mandated it.
 
G

Guest

Flash said:
Harald van Dijk wrote, On 17/01/07 15:29:

<snip>

Where does the C99 standard require implementations to use Unicode? It
*might* make it an explicit option but I would be very surprised if it
mandated it.

If they don't use some form of Unicode for their char/wchar_t, they
must convert the characters. 6.4.3p4 states:
"The universal character name \Unnnnnnnn designates the character whose
eight-digit short identiï¬er (as speciï¬ed by ISO/IEC 10646) is
nnnnnnnn.63) Similarly, the universal character name \unnnn designates
the character whose four-digit short identiï¬er is nnnn (and whose
eight-digit short identiï¬er is 0000nnnn)."

(The differences between Unicode and ISO/IEC 10646 are not relevant in
this case.)
 
F

Flash Gordon

Harald van Dijk wrote, On 21/01/07 11:09:
If they don't use some form of Unicode for their char/wchar_t, they
must convert the characters. 6.4.3p4 states:

<snip>

Thanks. That is useful to know. It would be even more useful if more
compilers supported C99, but that is a different issue ;-)
 
D

Daniel Molina Wegener

Gabriel said:
I am Latinanmerican an I would like to knonw how make accents using
printlf. Thanks.

You can try using the setlocale(3) and wchar_t related functions if you
are using wide chars.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,124
Latest member
JuniorPell
Top