spaces

file_get_contents with spaces in URL

那年仲夏 提交于 2019-12-01 17:16:05
I have an issue where even if I replace the spaces to %20 and get this content the ultimate url the browser gets turns the "%20" into "%2520" Here's my code, any suggestions to get this to work? it seems easy but I'm stuck :/ <?php //$_GET['song'] will contain a song name with spaces $song = str_replace(array("%20", "&", "?" , "/"), array(" ", "", "", ""), $_GET['song']); // I use this to check how the GET 'song' looks after the str_replace $list = "http://www.lyrdb.com/lookup.php?q=" . $song . "&for=fullt"; echo "list url is " . $list . "<hr>"; $content = file_get_contents("http://www.lyrdb

What's wrong with putting spaces in $_GET variables

。_饼干妹妹 提交于 2019-12-01 16:16:57
问题 If I for example have my url looking like index.php?category=IT%20&%20Soft. Then i try to print "$_GET[category]" i only get "IT" and not "IT & Soft". What is wrong here? It's frustrating me. 回答1: The problem is not the spaces, but the ampersand. Use %26 instead, like this: index.php?category=IT%20%26%20Soft The ampersand indicates that you are beginning another field (like category=IT&subcategory=somethingelse ). You can see a list of reserved characters on Wikipedia. 回答2: Spaces and

json fieldnames spaces

会有一股神秘感。 提交于 2019-12-01 15:56:59
I've such a json structure: info: { First Name: "Robert", Last Name: "Smith" } I'm tring to point to data with javascript using something like: "info.First Name" I know it's incorrect. How can I retrieve those information from the structure I have? thank That's not valid JSON. JSON is a data transport format that requires field names to be string delimited with double quotes , e.g. { "info" : { "First Name": "Robert", "Last Name": "Smith" } } After parsing, you can then use obj.info["First Name"] to access the First Name field. What you have is a JS object literal (that's still invalid), but

How to replace custom tabs with spaces in a string, depend on the size of the tab?

五迷三道 提交于 2019-12-01 15:32:32
I'm trying to write a python function not using any modules that will take a string that has tabs and replace the tabs with spaces appropriate for an inputted tabstop size. It can't just replace all size-n tabs by n spaces though, since a tab could be 1 to n spaces. I'm really confused, so if anyone could just point me in the right direction I'd greatly appreciate it. For instance, if tabstop is size 4 originally: 123\t123 = 123 123 #one space in between but changed to tabstop 5: 123\t123 = 123 123 #two spaces in between I think I need to pad the end of the string with spaces until string%n==0

json fieldnames spaces

拟墨画扇 提交于 2019-12-01 14:43:59
问题 I've such a json structure: info: { First Name: "Robert", Last Name: "Smith" } I'm tring to point to data with javascript using something like: "info.First Name" I know it's incorrect. How can I retrieve those information from the structure I have? thank 回答1: That's not valid JSON. JSON is a data transport format that requires field names to be string delimited with double quotes , e.g. { "info" : { "First Name": "Robert", "Last Name": "Smith" } } After parsing, you can then use obj.info[

Stop ConfigParser adding spaces to delims after upgrade from python 2.7.3 to 2.7.9

扶醉桌前 提交于 2019-12-01 14:06:57
After being forced to use a later version of python, ConfigParser now insists on adding spaces to each side of any delims when modifying a configuration file. e.g. setting=90 becomes: setting = 90 This was not the behavior in the earlier version, and I cannot find a way of controlling this behavior, can anyone help? My test code looks like this: import ConfigParser import os config = ConfigParser.ConfigParser() cfgfile = '/home/osmc/bin/test/config.txt' os.system('sudo echo "[section]" > ' + cfgfile) os.system('sudo echo "setting=0" >> ' + cfgfile) config.read(cfgfile) config.set('section',

Run programs with too many spaces

天大地大妈咪最大 提交于 2019-12-01 12:52:16
I have a command that works fine with command prompt: CMD /C ""C:\Program Files (x86)\VideoLAN\VLC\VLC" -vvv "http://www.foo.com:8085/video.mp4/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9NC8yNy8yMDE3IDEyO==" :sout=#file{dst="F:\\Partition C Backup\\Downloads\\Video\\TESTING.mp4",no-overwrite} :sout-keep"" Here I need CMD /C to return the errorlevel. That's how I tried to run this in VBScript using Run method: WshShell.Run "CMD /C ""C:\Program Files (x86)\VideoLAN\VLC\VLC" -vvv "http://www.foo.com:8085/video.mp4/playlist.m3u8?wmsAuthSign=c2VydmVyX3RpbWU9NC8yNy8yMDE3IDEyO==" :sout=#file{dst="F:\

Stop ConfigParser adding spaces to delims after upgrade from python 2.7.3 to 2.7.9

巧了我就是萌 提交于 2019-12-01 11:47:52
问题 After being forced to use a later version of python, ConfigParser now insists on adding spaces to each side of any delims when modifying a configuration file. e.g. setting=90 becomes: setting = 90 This was not the behavior in the earlier version, and I cannot find a way of controlling this behavior, can anyone help? My test code looks like this: import ConfigParser import os config = ConfigParser.ConfigParser() cfgfile = '/home/osmc/bin/test/config.txt' os.system('sudo echo "[section]" > ' +

BASH shell expand arguments with spaces from variable [duplicate]

前提是你 提交于 2019-12-01 11:12:33
This question already has an answer here: Bash doesn't parse quotes when converting a string to arguments 4 answers Say I have a variable $ARGS which contains the following: file1.txt "second file.txt" file3.txt How can I pass the contents of $ARGS as arguments to a command (say cat $ARGS , for example), treating "second file.txt" as one argument and not splitting it into "second and file.txt" ? Ideally, I'd like to be able to pass arguments to any command exactly as they are stored in a variable (read from a text file, but I don't think that's pertinent). Thanks! Charles Duffy It's possible

Building command strings using variables with various quote levels and spaces

≡放荡痞女 提交于 2019-12-01 08:39:53
I have a script that runs curl . I want to be able to optionally add a -H parameter, if a string isn't empty. What's complex is the levels of quoting and spaces. caption="Test Caption" if [ "${caption}" != "" ]; then CAPT=-H "X-Caption: ${caption}" fi curl -A "$UA" -H "Content-MD5: $MD5" -H "X-SessionID: $SID" -H "X-Version: 1" $CAPT http://upload.example.com/$FN The idea is that the CAPT variable is either empty, or contains the desired -H header in the same form as the others, e.g., -H "X-Caption: Test Caption" The problem is when run, it interprets the assignment as a command to be executed