Cannot create string with windows path



I’m trying to create a simple string variable to point to a path on windows. I will need to do the same in osx and unix, but just prototyping my stuff in windows. Here’s my path:

C:\Users\labadmin\Dropbox (HHMI)\bscope data for Bruno\my_data\11A92LexA-Chr-SS08888-Gc6-costim_20170216_160604_uFChrExperiment_00001.tif

I cannot simply enclose it in “” . If I start escaping characters, it works until


If I add more, I get this error

ArgumentError: \x used with no following hex digits in "C:\Users\labadmin\Dropbox (HHMI)\bscope data for Bruno\my_data\tF02LexA-Chr-SS02163-Gc6-costim_201702"
in yieldto(::Task, ::ANY) at event.jl:136
in wait() at event.jl:169
in wait(::Condition) at event.jl:27
in wait(::Task) at task.jl:132
in macro expansion at dynamic.jl:67 [inlined]
in (::Atom.##51#54)(::Dict{String,Any}) at eval.jl:52
in handlemsg(::Dict{String,Any}, ::Dict{String,Any}, ::Vararg{Dict{String,Any},N}) at comm.jl:163
in (::Atom.##14#17)() at event.jl:68

It also seems like I’ll have a hard time using numbers after escaping \'s in the path… What is the correct way to go about this?



Hmm, this works. No need to escape

pato = "C:\\Program Files (x86)";

julia> raw"C:\Users\labadmin\Dropbox (HHMI)\bscope data for Bruno\my_data\tF02LexA-Chr-SS02163-Gc6-costim_201702"

(for Julia 0.5 you’ll need to define: macro raw_str(s); s; end)


Only the backslashes need quoting here.
Should work if you use double backslashes \\.


I have just recently discovered raw"..." string literals in v0.6.

As a Windows user, I can’t begin to express how useful this is, especially when working at the REPL.
This small little macro has changed my life.
I now define it in my .juliarc.jl for v0.5.

Perhaps it can be backported to 0.5?


It could be put into Compat. We don’t backport new features into the base Julia itself, since that would violate the semantic versioning spec.