gtkD load images

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 5 13:59:13 PDT 2017


On 08/05/2017 10:30 PM, Mike Wey wrote:
> On 05-08-17 15:23, Johnson Jones wrote:
>> On Saturday, 5 August 2017 at 12:51:13 UTC, Mike Wey wrote:
[...]
>>> There are two issues here, you need to properly escape the slash: 
>>> "C:\\\\a.jpg".
[...]
>>> ```
>>> Pixbuf p = new Pixbuf(r"C:\\a.jpg");
>>> ```
>>
>> Thanks. Why do I need 4 slashes? Is that standard with gtk because 
>> strings are interpreted twice or something? Seemed to work though.
>>
>>
> 
> Nothing specific to GTK but in D and other programing languages the \ is 
> used as an escape character, so you can use special characters in your 
> sting like `\n` for a newline. But this means you will need to use \\ to 
> get an literal back slash.

I think you missed the point of the question.

In the end, the path should contain only one backslash. But with 
`"C:\\\\a.jpg"` and `r"C:\\a.jpg"` you get two. Why do you need two? 
Does the library do another round of escape sequence handling?


More information about the Digitalmars-d-learn mailing list