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

printf("%ls")

Is printf("%ls") for printing wchar_t strings defined in C90, or it was
added in C95?
Feb 28 '08 #1
3 33623
In article <fq***********@ulysses.noc.ntua.gr>,
Ioannis Vranos <iv*****@nospam.no.spamfreemail.grwrote:
>Is printf("%ls") for printing wchar_t strings defined in C90, or it was
added in C95?
It was not present in C89 -- which has a specific footnote for %s
indicating that no special provision is made for multibyte characters.
--
"All human knowledge takes the form of interpretation."
-- Walter Benjamin
Feb 28 '08 #2
Walter Roberson wrote:
In article <fq***********@ulysses.noc.ntua.gr>,
Ioannis Vranos <iv*****@nospam.no.spamfreemail.grwrote:
>Is printf("%ls") for printing wchar_t strings defined in C90, or it was
added in C95?

It was not present in C89 -- which has a specific footnote for %s
indicating that no special provision is made for multibyte characters.

So what is the need of printf("%ls") in C95 since we got wprintf()?

Wan't there any possibility to print wide-character strings or wchar_ts
under C90 directly?
Feb 28 '08 #3
Ioannis Vranos wrote:
So what is the need of printf("%ls") in C95 since we got wprintf()?
printf("%s") prints a multibyte character string to stdout as a sequence
of bytes.
printf("%ls") converts a wide character string to a multibyte character
string, and prints it out as a sequence of bytes.
wprintf("%s") converts a multibyte character string to a wide character
string, and prints it out as a sequence of wchar_t to stdout (which must
be wide-oriented). The wide-oriented stream will in turn convert the
wide characters into multibyte character sequences before writing.
wprintf("%ls") prints a wide character string to stdout (which must be
wide-oriented) as a sequence of wchar_t.

The only real difference between non-w* I/O functions and the w* ones,
is that the latter are for "wide oriented" streams while the former are
for byte-oriented streams. The results end up being the same, AIUI.

The only thing I can think of that would truly bother me not to have, if
I was forced to stick to pre-C95 code, is the lack of the wctype.h
stuff. That seems pretty important, to me, because without them, you can
convert mbc to wc, but you can't tell much _about_ that wc.

Ah, well.
Wan't there any possibility to print wide-character strings or wchar_ts
under C90 directly?
Yes. Use wcstombs() or somesuch, first. This is what %ls does implicitly
in printf().

(Disclaimer: this is all AIUI. I have very rarely used any of this
stuff, and so there may be major gaping holes in my understanidng. This
is from carefully reading, skimmed (but hopefully relevant), portions of
the C Standard.)

--
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
Feb 29 '08 #4

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

Similar topics

4
by: lovecreatesbeauty | last post by:
I read the following code in `Lions' Commentary on UNIX 6th Edition with Source Code'. The code in the book labeled from line 1516 to 1529 declaring "icode" is strange. Was one equal mark missed at...
4
by: marsarden | last post by:
code below: #include <stdio.h> int main(void) { char *aaa={"a","b","c"}; printf("%S\n",*aaa); /*the uppercase character S*/ getchar();
18
by: Stephan Beal | last post by:
Hi, all! Before i ask my question, i want to clarify that my question is not about the code i will show, but about what the C Standard says should happen. A week or so ago it occurred to me...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.