escaped-characters

Why doesn't this escape character actually work in Ruby?

code: file.write 'objectclass: groupOfUniqueNames\n' Oddly enough, the \n is actually being printed... What is wrong here? ...

How can I avoid SQL injection attacks?

Yesterday I was speaking with a developer, and he mentioned something about restricting the insertions on database field, like, strings such as -- (minus minus). At the same type, what I know is that is a good approach to escape HTML chars like <, > etc. Not --. Is this true? Do I have to worry about --, ++? Is it more like a myth or ol...

Don't want RedirectToAction() escape "plus" characters

I'm trying to do something similar to what Stackoverflow is doing. I have a quick search text box and I can put an arbitrary number of words into in and submit my search. Receiving action does this (shortened version) public ActionResult Search(string query) { Regex rx = new Regex("(?<word>[a-zA-Z0-9]+)"); StringBuilder parts = new ...

Best way to split a string into tokens skipping escaped delimiters?

I'm receiving an NSString which uses commas as delimiters, and a backslash as an escape character. I was looking into splitting the string using componentsSeparatedByString, but I found no way to specify the escape character. Is there a built-in way to do this? NSScanner? CFStringTokenizer? If not, would it be better to split the string...

Regular expression with an = and a ;

I'm trying to use a regular expression to find all substrings that start with an equals sign (=) and ends with a semicolon (;) with any number of characters in between. It should be something like this =*; For some reason, the equals is not registering. Is there some sort of escape character that will make the regex notice my equals sig...

How to pass in a null character in a command line argument in C?

I would still like to know how to pass in a null character as a command line argument, maybe so that a single string can be passed in as an argument in the form: "to\0be\0or\0not\0to\0be\0" And then parse it. However the program would treat this string as: "to\\0be\\0or\\0not\\0to\\0be\\0" How can I work around this? Is ther...

C# - What does "\0" equate to?

I am playing with Pex and one of the parameters it passes into my method is "\0". What does that mean? My guess is an empty string ("") based on the content of my method. However, if it is the same then why not just use "" instead of "\0"? Anyone know what it is? ...

Passing a string with apostrophe to javascript function

I have a situation where I need to pass a string with an apostrophe in it to a javascript function. This function then takes the string and uses it to find the element by id in the DOM. As an example, I need to call: showElement('what's') function showElement(element_id){ document.getElementById(element_id).style.display = "bloc...

What's the VT100 escape code for the "esc" keyboard key itself

I'm writing a script to navigate a text-based menu system, using python's telnetlib to access a serial connection. I can happily press the F-keys, using the escape codes. e.g. F9 = "\033OX", where "\033" is the escape sequence. How do I encode the "esc" keyboard key? I would have expected just "\033", but that doesn't seem to work. ...

How can I replace a plus sign in JavaScript?

I need to make a replace of a plus sign in a javascript string. there might be multiple occurrence of the plus sign so I did this up until now: myString= myString.replace(/+/g, "");# This is however breaking up my javascript and causing glitches. How do you escape a '+' sign in a regular expression? ...

Why are my "+" characters turned into spaces in my CGI program that handles Ajax requests?

I'm collecting text through a web form and noticing that when it is collected by my Perl CGI all instances of "+" are transformed into " ". I run the text through a JavaScript escape before submission, but escape seems to leave + unaltered. There must be something really obvious that I'm missing... how do I send the string "2 + 2 = 4"...

C# double-quoted path name being escaped when read from file

I am trying to read in a text input file that contains a list of filenames (one per line). However, I am running into an issue if the user double-quotes the path (because it has a space in it). For example, a normal input file might have: C:\test\test.tiff C:\test\anothertest.tiff C:\test\lasttest.tiff These get read in fine by my cod...

Passing string with (accidental) escape character loses character even though it's a raw string

I have a function with a python doctest that fails because one of the test input strings has a backslash that's treated like an escape character even though I've encoded the string as a raw string. My doctest looks like this: >>> infile = [ "Todo: fix me", "/** todo: fix", "* me", "*/", r"""//\todo stuff to fix""", "TODO f...

Escape apostrophes inside double quoted strings (Javascript)

Say i have a string that i need to evaluate in javascript such as : window.some_class.update( 'Runner', 'update_runner', '{"runner":{"id":"1","name":"Nin's Lad" } }'); In order for eval() to evaluate it, i need to escape the apostrophe in runner_name (Nin's Lad). Is this possable with regex? I dont want to escape the single quotes aro...

How can I manually interpolate string escapes in a Perl string?

In perl suppose I have a string like 'hello\tworld\n', and what I want is: 'hello world ' That is, "hello", then a literal tab character, then "world", then a literal newline. Or equivalently, "hello\tworld\n" (note the double quotes). In other words, is there a function for taking a string with escape sequences and returning an eq...

Javascript search and replace sequence of characters that contain square brackets

Hello all I'm trying to search for '[EN]' in the string 'Nationality [EN] [ESP]', I want to remove this from the string so I'm using a replace method, code examaple below var str = 'Nationality [EN] [ESP]'; var find = "[EN]"; var regex = new RegExp(find, "g"); alert(str.replace(regex, '')); Since [EN] is identified as a character set...

Bizarre Escape Character Question

I have the following c# code embedded in a literal <% %> of a c# asp.net page string commandString = "SELECT tblData.Content " + "FROM tblData " + "WHERE (tblData.ref = N\'%"+myCurrentREF+"%\')"; This is breaking my code since it apparently cannot use the \' escape character. Why is it s...

Ruby HTML scraper written in Hpricot having trouble with escaped HTML

I am trying to scrape this page: http://www.udel.edu/dining/menus/russell.html. I have written a scraper in Ruby using the Hpricot library. problem: HTML page is escaped and I need to display it unescaped example: "M&amp;M" should be "M&M" example: "Entr&eacute;e" should be "Vegetarian Entrée" I have tried using the CGI library...

Show escaped string as Unicode in Python

Hello, i have just known Python for few days. Unicode seems to be a problem with Python. i have a text file stores a text string like this '\u0110\xe8n \u0111\u1ecf n\xfat giao th\xf4ng Ng\xe3 t\u01b0 L\xe1ng H\u1ea1' i can read the file and print the string out but it displays incorrectly. How can i print it out to screen correctly ...

parse this directory path without losing slash

hi, I have a wxPython application. I am taking in a directory path from a textbox using GetValue(). I notice that while trying to write this string to a variable: "C:\Documents and Settings\tchan\Desktop\InputFile.xls", python sees the string as 'C:\\Documents and Settings\tchan\\Desktop\\InputFile.xls' (missing a slash between "...