Jump to page: 1 2
Thread overview
utf-8?
Mar 17, 2009
Steve Teale
Mar 17, 2009
Ary Borenszweig
Mar 17, 2009
Trass3r
Mar 17, 2009
Steve Teale
Mar 17, 2009
Ary Borenszweig
Mar 17, 2009
Walter Bright
Mar 17, 2009
Georg Wrede
Mar 17, 2009
Gide Nwawudu
Mar 18, 2009
Denis Koroskin
Mar 18, 2009
Steve Teale
Mar 18, 2009
Daniel Keep
March 17, 2009
import std.stdio;

void main()
{
   string s = "Die Walküre";
   writefln(s);
}

Gives error - invalid utf-8 sequence. I pasted the text from a Wiki page that claims to be utf-8. What's happening?
March 17, 2009
Steve Teale wrote:
> import std.stdio;
> 
> void main()
> {
>    string s = "Die Walküre";
>    writefln(s);
> }
> 
> Gives error - invalid utf-8 sequence. I pasted the text from a Wiki page that claims to be utf-8. What's happening?

Did you save the file as UTF-8?
March 17, 2009
Steve Teale wrote:
> import std.stdio;
> 
> void main()
> {
>    string s = "Die Walküre";
>    writefln(s);
> }
> 
> Gives error - invalid utf-8 sequence. I pasted the text from a Wiki
> page that claims to be utf-8. What's happening?

I pasted your code above and compiled and ran it with no problem.
I'm on linux: Fedora 10, and dmd v2.026.



March 17, 2009
Ary Borenszweig schrieb:
>> Gives error - invalid utf-8 sequence. I pasted the text from a Wiki page that claims to be utf-8. What's happening?
> 
> Did you save the file as UTF-8?

Yeah, you must save the file as UTF-8.
March 17, 2009
Ary Borenszweig Wrote:

> Steve Teale wrote:
> > import std.stdio;
> > 
> > void main()
> > {
> >    string s = "Die Walküre";
> >    writefln(s);
> > }
> > 
> > Gives error - invalid utf-8 sequence. I pasted the text from a Wiki page that claims to be utf-8. What's happening?
> 
> Did you save the file as UTF-8?

Was not offered the opportunity. I pasted the text from the web page into Windows Notepad, and saved it - this seemed to me to be as generic as possible given the facilities I have available. What editor will do the trick? Also, if I'm using the Windows version of the compiler, shouldn't it be smart enough to convert the Windows character set to UTF-8?

March 17, 2009
Steve Teale wrote:
> Ary Borenszweig Wrote:
> 
>> Steve Teale wrote:
>>> import std.stdio;
>>>
>>> void main()
>>> {
>>>    string s = "Die Walküre";
>>>    writefln(s);
>>> }
>>>
>>> Gives error - invalid utf-8 sequence. I pasted the text from a Wiki page that claims to be utf-8. What's happening?
>> Did you save the file as UTF-8?
> 
> Was not offered the opportunity. I pasted the text from the web page into Windows Notepad, and saved it - this seemed to me to be as generic as possible given the facilities I have available. What editor will do the trick? Also, if I'm using the Windows version of the compiler, shouldn't it be smart enough to convert the Windows character set to UTF-8?

Notepad will do the trick, but you must save it as UTF-8. In the Save As dialog select UTF-8 in Encoding.
March 17, 2009
Steve Teale wrote:
> Also, if I'm using the Windows version of
> the compiler, shouldn't it be smart enough to convert the Windows
> character set to UTF-8?

The huge problem with code pages is, given a file with some text in it, there is NO CLUE what code page the file's text encoding is in. Just because dmd is running on Windows is not any reason at all that the character set of the file must be the Windows character set.

I ran into this problem all the time with C code.

March 17, 2009
On Tue, 17 Mar 2009 10:48:56 -0400, Steve Teale <steve.teale@britseyeview.com> wrote:

>import std.stdio;
>
>void main()
>{
>   string s = "Die Walküre";
>   writefln(s);
>}
>
>Gives error - invalid utf-8 sequence. I pasted the text from a Wiki page that claims to be utf-8. What's happening?

Works for me, you should save the file as UTF-8 and set your codepage
to 65001.
C:\> dmd test.d

C:\> test
Die Walk+?re

C:\>chcp 65001
Active code page: 65001

C:\>test
Die Walküre

Gide
March 18, 2009
On Wed, 18 Mar 2009 02:34:49 +0300, Gide Nwawudu <gide@btinternet.com> wrote:

> On Tue, 17 Mar 2009 10:48:56 -0400, Steve Teale
> <steve.teale@britseyeview.com> wrote:
>
>> import std.stdio;
>>
>> void main()
>> {
>>   string s = "Die Walküre";
>>   writefln(s);
>> }
>>
>> Gives error - invalid utf-8 sequence. I pasted the text from a Wiki page that claims to be utf-8. What's happening?
>
> Works for me, you should save the file as UTF-8 and set your codepage
> to 65001.
> C:\> dmd test.d
>
> C:\> test
> Die Walk+?re
>
> C:\>chcp 65001
> Active code page: 65001
>
> C:\>test
> Die Walküre
>
> Gide

I believe Phobos should do it manually.

March 18, 2009
Gide Nwawudu Wrote:

> On Tue, 17 Mar 2009 10:48:56 -0400, Steve Teale <steve.teale@britseyeview.com> wrote:
> 
> >import std.stdio;
> >
> >void main()
> >{
> >   string s = "Die Walküre";
> >   writefln(s);
> >}
> >
> >Gives error - invalid utf-8 sequence. I pasted the text from a Wiki page that claims to be utf-8. What's happening?
> 
> Works for me, you should save the file as UTF-8 and set your codepage
> to 65001.
> C:\> dmd test.d
> 
> C:\> test
> Die Walk+?re
> 
> C:\>chcp 65001
> Active code page: 65001
> 
> C:\>test
> Die Walküre
> 
> Gide

Yup, that does it. I'd missed the encoding option in notepad. What were you running the program in - in a cmd window I see graphics characters.
« First   ‹ Prev
1 2