December 15, 2012
I'm trying to understand how strings are working in D. I got the following error when declaring a simple string variable: "Invalid trailing code unit":

wstring needle = `Être sans la verité`;

Considering that the line obove is copied exactl from the site examples, what I'm doing wrong?


December 15, 2012
On Saturday, 15 December 2012 at 06:07:10 UTC, rumbu wrote:
> I'm trying to understand how strings are working in D. I got the following error when declaring a simple string variable: "Invalid trailing code unit":
>
> wstring needle = `Être sans la verité`;
>
> Considering that the line obove is copied exactl from the site examples, what I'm doing wrong?

works for me and on the DPaste site:
http://dpaste.dzfl.pl/00b66ba8

what platform are you on and what version of D are you using?
are you passing any compiler flags or just running plain ol' "$>rdmd test.d" ?

December 15, 2012
On Saturday, 15 December 2012 at 06:22:50 UTC, Joshua Niehus wrote:
> On Saturday, 15 December 2012 at 06:07:10 UTC, rumbu wrote:
>> I'm trying to understand how strings are working in D. I got the following error when declaring a simple string variable: "Invalid trailing code unit":
>>
>> wstring needle = `Être sans la verité`;
>>
>> Considering that the line obove is copied exactl from the site examples, what I'm doing wrong?
>
> works for me and on the DPaste site:
> http://dpaste.dzfl.pl/00b66ba8
>
> what platform are you on and what version of D are you using?
> are you passing any compiler flags or just running plain ol' "$>rdmd test.d" ?

I'm using D-Ide, compiling with "DMD32 D Compiler v2.060" with the following arguments: -c "$src" -of"$obj" $importPaths -gc -debug -w -unittest

December 15, 2012
On 12/14/2012 10:07 PM, rumbu wrote:
> I'm trying to understand how strings are working in D. I got the
> following error when declaring a simple string variable: "Invalid
> trailing code unit":
>
> wstring needle = `Être sans la verité`;
>
> Considering that the line obove is copied exactl from the site examples,
> what I'm doing wrong?

Works here as well.

My guess is that the encoding of the source code is not one of the Unicode encodings, rather a "code table" encoding. If so, please save the source code in a UTF encoding, e.g. UTF-8.

Ali

December 15, 2012
On Saturday, 15 December 2012 at 06:37:51 UTC, Ali Çehreli wrote:
>
> Works here as well.
>
> My guess is that the encoding of the source code is not one of the Unicode encodings, rather a "code table" encoding. If so, please save the source code in a UTF encoding, e.g. UTF-8.
>
> Ali


Yes, it was ANSI encoded (I think this is the default encoding in D-IDE), I converted the file to UTF-8 and it's compiling.

Thanks for your help.
Top | Discussion index | About this forum | D home