gtkD load images

Mike Wey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 6 02:37:57 PDT 2017


On 05-08-17 22:59, ag0aep6g wrote:
> 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?

That's me not being a Windows user shining trough, i somehow got it in 
my head that you needed two backslashes after the C:.

But indeed just "C:\\a.jpg" or r"C:\a.jpg" will work as expected.

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list