backslashes

PHP replace double backslashes "\\" to a single backslash "\"

Okay so im working on this php image upload system but for some reason internet explorer turns my basepath into the same path, but with double backslashes instead of one; ie: C:\\Documents and Settings\\kasper\\Bureaublad\\24.jpg This needs to become C:\Documents and Settings\kasper\Bureaublad\24.jpg. ...

Echo A Link, Get A Trailing Slash?

I've discovered that any time I do the following: echo '<a href="http://" title="bla">huzzah</a>'; I end up with the following being rendered to the browser: <a href="http:///" title="bla">huzzah</a> This is particularly annoying when I link to a file with an extension, as it breaks the link. Any ideas why this is happening and ho...

C++ include header path change windows to linux

Hi, I am porting a application written in c++ from windows to Linux. I have a problem with the header files path. Windows uses "\" and while Linux uses "/" . I am finding it cumbersome to change this in each and every source and header file. Is there some work around? ...

How to avoid double backslash in MySQL's SELECT INTO OUTFILE

In MySQL, the following: SELECT '\\' INTO OUTFILE 'c:/temp/backslash.dump'; writes two backslashes to the file, which makes sense. Trying to dump a single backslash, I changed SQL_MODE, like that: SET SESSION SQL_MODE='NO_BACKSLASH_ESCAPES'; SELECT '\' INTO OUTFILE 'c:/temp/backslash.dump'; but got two backslashes again. Is t...

Backslashes in Single quoted strings vs. Double quoted strings in Ruby?

I'm a little confused about when to use single quoted strings versus double quoted strings. I've noticed that if I put a variable inside a single quoted string, it doesn't get interpreted. Also, if I use a newline character in a double quoted string, it causes the string to be displayed over two lines whereas in a single quoted string th...

Escaping Strings in JavaScript

Hello, Does JavaScript have a built-in function like PHP's addslashes (or addcslashes) function to add backslashes to characters that need escaping in a string? For example, this: This is a demo string with 'single-quotes' and "double-quotes". ...would become: This is a demo string with \'single-quotes\' and \"double-qu...

How can I canonicalize Windows file paths in Perl?

Update: I can make this a simpler problem to solve: I want to figure out what the correct regex would be to substitute any single occurrence of a back slash with two back slashes. I want to turn this: vlc.plugin.path = C:\Program Files\JekyllV0.9.2\\VLC_1.0.0\\plugins into: vlc.plugin.path = C:\\Program Files\\JekyllV0.9.2\\VLC_1....

Weird backslash substitution in Ruby

I don't understand this Ruby code: >> puts '\\ <- single backslash' # \ <- single backslash >> puts '\\ <- 2x a, because 2 backslashes get replaced'.sub(/\\/, 'aa') # aa <- 2x a, because two backslashes get replaced so far, all as expected. but if we search for 1 with /\\/, and replace with 2, encoded by '\\\\', why do we get this: ...

So what IS the right direction of the path's slash (/ or \) ?

it seems windows insist on writing this slash on files' path \, while .net's URI class writing this the other way? Is there any right way? that is accepted even in the most primitive systems? And why the .net's URI is showing the other slash than windows does? Thanks. ...

Replacing backslashes in Python strings

I have some code to encrypt some strings in Python. Encrypted text is used as a parameter in some urls, but after encrypting, there comes backslashes in string and I cannot use single backslash in urllib2.urlopen. I cannot replace single backslash with double. For example: print cipherText '\t3-@\xab7+\xc7\x93H\xdc\xd1\x13G\xe1\xfb' ...

net.sf.json.JSONObject adds backslashes where it's not expected ?

Hi there, I'm loosing my hair trying to figure out why net.sf.json.JSONObject add extra backslash where it shouldn't on my java code : JSONObject obj = new JSONObject (); obj.element ("column_name", "<a href=\"#\" title=\"test\">Test !</a>"); will output : <a href=\"#\" title=\"test\">Test !<\/a> with an extra "\" near <\/a>. How...

I want one backslash - not two

I have a string that after print is like this: \x4d\xff\xfd\x00\x02\x8f\x0e\x80\x66\x48\x71 But I want to change this string to "\x4d\xff\xfd\x00\x02\x8f\x0e\x80\x66\x48\x71" which is not printable (it is necessary to write to serial port). I know that it ist problem with '\'. how can I replace this printable backslashes to unprintable?...