Hi,

I am trying to create some wide characters but I get a warning when I
compile the code.

Here is my code
wchar_t test = L'fi';

the warning is this.
warning C4066: characters beyond first in wide-character constant
ignored

And just as the warning says the character is set to L'f'

If I set it using the hex value it works but the code is far less
readable.
wchar_t testr = L'\xfb01';

Any idea what is wrong here?

Vin

Re: wide characters not accepted by Carl

Carl
Fri Oct 27 09:18:42 CDT 2006

Vincent Finn wrote:
> Hi,
>
> I am trying to create some wide characters but I get a warning when I
> compile the code.
>
> Here is my code
> wchar_t test = L'fi';
>
> the warning is this.
> warning C4066: characters beyond first in wide-character constant
> ignored
>
> And just as the warning says the character is set to L'f'
>
> If I set it using the hex value it works but the code is far less
> readable.
> wchar_t testr = L'\xfb01';
>
> Any idea what is wrong here?

It looks like your expectations are wrong. L'fi' has two characters
surrounded by apostrophes, and as the compiler indicates, everything past
the first character is ignored.

L'\xfb01' has a single character, expressed as a 4-digit hexadecimal code
between apostrophes.

If you're trying to write the single character ligature L'?', then you need
to make sure that your source code is stored in a Unicode format (typically
UTF-8) and that you're using VC7 or later (VC6 doesn't support unicode
source files, IIRC).

-cd



Re: wide characters not accepted by John

John
Fri Oct 27 09:30:53 CDT 2006

"Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nospam@mvps.org.nospam> wrote in message
news:OezfPLd%23GHA.4704@TK2MSFTNGP04.phx.gbl
> Vincent Finn wrote:
>> Hi,
>>
>> I am trying to create some wide characters but I get a warning when I
>> compile the code.
>>
>> Here is my code
>> wchar_t test = L'fi';
>>
>> the warning is this.
>> warning C4066: characters beyond first in wide-character constant
>> ignored
>>
>> And just as the warning says the character is set to L'f'
>>
>> If I set it using the hex value it works but the code is far less
>> readable.
>> wchar_t testr = L'\xfb01';
>>
>> Any idea what is wrong here?
>
> It looks like your expectations are wrong. L'fi' has two characters
> surrounded by apostrophes, and as the compiler indicates, everything
> past the first character is ignored.
>
> L'\xfb01' has a single character, expressed as a 4-digit hexadecimal
> code between apostrophes.
>
> If you're trying to write the single character ligature L'?', then
> you need to make sure that your source code is stored in a Unicode
> format (typically UTF-8) and that you're using VC7 or later (VC6
> doesn't support unicode source files, IIRC).
>
> -cd

As an addendum, you can use the Character Map program that ships with
Windows (under Accessories->System Tools) to insert the ligature character
into your source code. (There may be other ways to do it.)


--
John Carson



Re: wide characters not accepted by Carl

Carl
Fri Oct 27 10:28:42 CDT 2006

John Carson wrote:
> "Carl Daniel [VC++ MVP]"
>> If you're trying to write the single character ligature L'?', then
>> you need to make sure that your source code is stored in a Unicode
>> format (typically UTF-8) and that you're using VC7 or later (VC6
>> doesn't support unicode source files, IIRC).
>
> As an addendum, you can use the Character Map program that ships with
> Windows (under Accessories->System Tools) to insert the ligature
> character into your source code. (There may be other ways to do it.)

Exactly. I'd actually done just that to insert the 'fi' ligature above, but
it looks like the encoding that OE used to send the page turned it into a ?.
Oh well.

-cd



Re: wide characters not accepted by Vincent

Vincent
Tue Oct 31 04:27:55 CST 2006

On Fri, 27 Oct 2006 08:28:42 -0700, "Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nospam@mvps.org.nospam> wrote:

>John Carson wrote:
>> "Carl Daniel [VC++ MVP]"
>>> If you're trying to write the single character ligature L'?', then
>>> you need to make sure that your source code is stored in a Unicode
>>> format (typically UTF-8) and that you're using VC7 or later (VC6
>>> doesn't support unicode source files, IIRC).
>>
>> As an addendum, you can use the Character Map program that ships with
>> Windows (under Accessories->System Tools) to insert the ligature
>> character into your source code. (There may be other ways to do it.)
>
>Exactly. I'd actually done just that to insert the 'fi' ligature above, but
>it looks like the encoding that OE used to send the page turned it into a ?.
>Oh well.
>
>-cd
>

OK, that makes sense.
My source code isn't Unicode so I'll stick with the long version.

Thanks, Vin

Re: wide characters not accepted by Tom

Tom
Tue Oct 31 04:55:21 CST 2006

Vincent Finn wrote:
> Hi,
>
> I am trying to create some wide characters but I get a warning when I
> compile the code.
>
> Here is my code
> wchar_t test = L'fi';

Here's mine:
wchar_t test = 'û\1';

> the warning is this.
> warning C4066: characters beyond first in wide-character constant
> ignored

So use a narrow character constant.

> If I set it using the hex value it works but the code is far less
> readable.
> wchar_t testr = L'\xfb01';
>
> Any idea what is wrong here?

I don't understand why 'fi' would be the same as '\xfb01'? 'û\1' does
appear to be the same from a quick test (assuming my news reader doesn't
mess up the encoding!). Note that multicharacter character literals have
type int, and have implementation defined behaviour.

Tom

Re: wide characters not accepted by Carl

Carl
Tue Oct 31 08:42:37 CST 2006

Tom Widmer [VC++ MVP] wrote:

> I don't understand why 'fi' would be the same as '\xfb01'? 'û\1' does
> appear to be the same from a quick test (assuming my news reader
> doesn't mess up the encoding!). Note that multicharacter character
> literals have type int, and have implementation defined behaviour.

Since Unicode code point xfb01 is the ligature 'fi' as a single character,
'fi' shouldn't be the same, but L'fi' sould be the same, assuming that's the
single character \xfb01 between those quotes and not the two characters 'f'
and 'i'..

-cd



Re: wide characters not accepted by Tom

Tom
Tue Oct 31 10:31:21 CST 2006

Carl Daniel [VC++ MVP] wrote:
> Tom Widmer [VC++ MVP] wrote:
>
>> I don't understand why 'fi' would be the same as '\xfb01'? 'û\1' does
>> appear to be the same from a quick test (assuming my news reader
>> doesn't mess up the encoding!). Note that multicharacter character
>> literals have type int, and have implementation defined behaviour.
>
> Since Unicode code point xfb01 is the ligature 'fi' as a single character,
> 'fi' shouldn't be the same, but L'fi' sould be the same, assuming that's the
> single character \xfb01 between those quotes and not the two characters 'f'
> and 'i'..

Ahh, I see.

Thanks,

Tom