quotes

Replacing quotation marks with “``” and “''”

吃可爱长大的小学妹 提交于 2019-12-01 23:26:14
I have a document containing many " marks, but I want to convert it for use in TeX. TeX uses 2 ` marks for the beginning quote mark, and 2 ' mark for the closing quote mark. I only want to make changes to these when " appears on a single line in an even number (e.g. there are 2, 4, or 6 " 's on the line). For e.g. "This line has 2 quotation marks." --> ``This line has 2 quotation marks.'' "This line," said the spider, "Has 4 quotation marks." --> ``This line,'' said the spider, ``Has 4 quotation marks.'' "This line," said the spider, must have a problem, because there are 3 quotation marks." -

How can I properly escape JavaScript in JavaScript?

馋奶兔 提交于 2019-12-01 22:58:51
This might be something I can't do but... parent.document.getElementById('<?php echo $_GET['song']; ?>') .innerHTML = '<img src="heart.png" onmouseover="heartOver('');" >'; The onmouseover="heartOver(''); portion breaks my JavaScript. Is there a way to escape the quotes so I can do this? Escape nested quotes with a backslash: \' Also, never echo user data without validating or sanitizing it: $song = $_GET['song']; // Validate HTML id (http://www.w3.org/TR/REC-html40/types.html#type-name) if(!preg_match('/^[a-z][-a-z0-9_:\.]*$/', $song) { // Display error because $song is invalid } OR //

php - convert single quoted string to double quoted

怎甘沉沦 提交于 2019-12-01 22:47:13
Been searching here and google for over an hour, can't seem to find the answer to this. I have a string returned from a database query which contains variables, however it appears that these strings are all returned single-quoted and therefore the variables are not evaluated as they would be if it was double quoted. what is returned from the sql query would be the $result: This will not evaluate the 2 variables: $myname = 'david'; $occupation = 'Beginner'; $result = 'Hello my name is $myname and I my occupation is $occupation'; echo $result; This will evaluate the 2 variables: $myname = 'david

PHP中magic quotes说明

北战南征 提交于 2019-12-01 22:28:42
特地查看了下手册,关于php magic quotes,常见的几个设置如下,magic_quotes_gpc,magic_quotes_sybase,magic_quote_runtime,这几个函数是在php.ini中去配置的,从手册中可以看出从php5.3后已经废除了这些函数,所以强烈大家不要使用,在php.ini中关闭它。 这些函数的作用是对数据进行转义。 防止sql注入的 时候,很多人会这样写: if (! get_magic_quotes_gpc ()) { $post = addslashes ( $post ); } 如果开启了它们,会自动给你转义单引号( ' )、双引号( " )、反斜线( \ )与 NUL( null字符 ),其实就相当于调用addslashes函数。你可能会说这样不是很好嘛,安全性更高了,但是,你考虑代码移植性了吗?另外,对于上所有gpc($_GET,$_POST,$_COOKIE)的数据你都进行转义是否有必要?开销有多大?下面PHP点点通(phpddt.com)就对手册中关于Magic Quotes的详细说明: 1.magic_quotes_gpc magic_quotes_gpc这个是用来设置GPC($_GET、$_POST、$_COOKIE)的魔术引用状态(在PHP4中也包含$_ENV)。当开启时,所有的单引号(single-quote)

Using quotation marks in Javascript with innerHTML

五迷三道 提交于 2019-12-01 20:01:55
I have written some code to update the player on the story as it progresses. When the player clicks a button they are greeted with some new text and some more options. So far so good, but when I pass a function call in with a parameter attached, I need both single and double quote marks. However, if I use both then this breaks the innerHTML. Code is as follows (can post HTML too if need be): function buttonClicked(buttonid) { switch(buttonid) { case "YesStart": document.getElementById("storybox").innerHTML = "Initially she fails to notice you and stares into the distance with dazed look of

How to quote in HTML (not blockquote)?

偶尔善良 提交于 2019-12-01 18:42:56
问题 I want to some sample code in a html page. How do I do it, for example I want to show a tag and image tag, in stackoverflow I use 4 spaces: A Tag example: <a href="your_url"></a> Image Tag example: <img...> 回答1: I think you're asking for the <pre> tag for preformatted text. Everything that goes inside the pre tag it's not interpreted. Try this on a browser: <pre> <img src="whatever" /> <othertag>whatever</otherta> </pre> EDIT: As Pekka pointed out, for HTML tags, symbols must be converted to

Using the replace operator on a string that has quotes powershell

放肆的年华 提交于 2019-12-01 18:09:54
问题 I am looking to run the command foreach-object {$_ -replace However the string I am attempting to work with could be described as the follow this string "has" quotes the whole line being foreach-object {$_ -replace "this string "has" quotes", "this string "won't have" quotes"} How do I make this quote filled line work with powershell? 回答1: You can either escape the nested double quotes like so `" or better yet, use single quotes for quoting of the string then you won't need to escape the

Using the replace operator on a string that has quotes powershell

末鹿安然 提交于 2019-12-01 18:03:11
I am looking to run the command foreach-object {$_ -replace However the string I am attempting to work with could be described as the follow this string "has" quotes the whole line being foreach-object {$_ -replace "this string "has" quotes", "this string "won't have" quotes"} How do I make this quote filled line work with powershell? You can either escape the nested double quotes like so `" or better yet, use single quotes for quoting of the string then you won't need to escape the double quotes e.g.: 'this string "has" quotes' Note: with single quotes you won't get variable expansion in a

standard way to convert to short path in .net

丶灬走出姿态 提交于 2019-12-01 17:23:16
looking for the standard bug-proofed way to convert "long names" such as "C:\Documents and settings" to their equivalent "short names" "C:\DOCUME~1" I need this to run an external process from withing my C# app. It fails if I feed it with paths in the "long name". Does the external process fail even if you enclose the long file paths in quotes? That may be a simpler method, if the external app supports it. e.g. myExternalApp "C:\Documents And Settings\myUser\SomeData.file" David Arno If you are prepared to start calling out to Windows API functions, then GetShortPathName() and GetLongPathName(

standard way to convert to short path in .net

余生长醉 提交于 2019-12-01 16:31:42
问题 looking for the standard bug-proofed way to convert "long names" such as "C:\Documents and settings" to their equivalent "short names" "C:\DOCUME~1" I need this to run an external process from withing my C# app. It fails if I feed it with paths in the "long name". 回答1: Does the external process fail even if you enclose the long file paths in quotes? That may be a simpler method, if the external app supports it. e.g. myExternalApp "C:\Documents And Settings\myUser\SomeData.file" 回答2: If you