Re: Using MBCS in a UNICODE defined project
- From: "Mihai N." <nmihai_year_2000@xxxxxxxxx>
- Date: Tue, 15 May 2007 23:42:15 -0700
This looks odd:Yes, it is a bit odd.
if( fgets( buffer, sizeof(buffer)/sizeof(buffer[0]), f ) )
sizeof(buffer)/sizeof(buffer[0]) is the same with sizeof(buffer) here
because buffer is always char (not using the generic API)
Just wanted to show "the right way" of calculating character count.
Does fgets really count characters the way MSDN says? Or does it use theI see no contradiction between MSDN and the C++ standard.
word "characters" with the meaning of "bytes", as would happen when copying
and pasting from the C or C++ standard?
The MSDN meaning is "what the programmer understands by character" (code unit
in the Unicode lingo), not "what the user understands by character"
So MSDN basically says number of char(s), same as number of byte(s).
MSDN says that Visual Studio 2005 added an optional ccs specification toccs does no affect how _fgetts counts characters.
the
second parameter of _tfopen but you didn't use it. If you did use it, it's
not exactly obvious if there would be some effect on the way fgets and
fgetws and _fgetts count characters.
_tfopen affects the code page for the opened file, _fgetts count characters
after a code page conversion (if it happens)
So opening a utf-8 file (using ccs) and reading with fgetws means the
utf-8 stream is read, converted to utf-16, and the counter for fgetws
is the number of code units (16 bit each).
optional ccs specification to theBecause the request is to get Chinese MBCS strings and pass them as
second parameter of _tfopen but you didn't use it
is to a function. So I did not want any encoding smartness from ccs.
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
.
- References:
- Using MBCS in a UNICODE defined project
- From: hamishd
- Re: Using MBCS in a UNICODE defined project
- From: David Wilkinson
- Re: Using MBCS in a UNICODE defined project
- From: Bob Eaton
- Re: Using MBCS in a UNICODE defined project
- From: hamishd
- Re: Using MBCS in a UNICODE defined project
- From: Mihai N.
- Re: Using MBCS in a UNICODE defined project
- From: hamishd
- Re: Using MBCS in a UNICODE defined project
- From: Mihai N.
- Re: Using MBCS in a UNICODE defined project
- From: Norman Diamond
- Using MBCS in a UNICODE defined project
- Prev by Date: Re: Rename a directory
- Next by Date: Re: How to XPStyles to be retained when the theme is classic on an XP Machine
- Previous by thread: Re: Using MBCS in a UNICODE defined project
- Next by thread: Re: Using MBCS in a UNICODE defined project
- Index(es):
Relevant Pages
|