invalid-characters

Cannot get xslt to output an (&) even after escaping the character

别说谁变了你拦得住时间么 提交于 2019-11-29 05:34:44
I am trying to create a query string of variable assignments separated by the & symbol (ex: "var1=x&var2=y&..." ). I plan to pass this string into an embedded flash file. I am having trouble getting an & symbol to show up in XSLT. If I just type & with no tags around it, there is a problem rendering the XSLT document. If I type & with no tags around it, then the output of the document is & with no change. If I type <xsl:value-of select="&" /> or <xsl:value-of select="&" /> I also get an error. Is this possible? Note: I have also tried &amp; with no success. Kevin Hakanson You can combine

Base64 String throwing invalid character error

旧巷老猫 提交于 2019-11-29 03:35:16
I keep getting a Base64 invalid character error even though I shouldn't. The program takes an XML file and exports it to a document. If the user wants, it will compress the file as well. The compression works fine and returns a Base64 String which is encoded into UTF-8 and written to a file. When its time to reload the document into the program I have to check whether its compressed or not, the code is simply: byte[] gzBuffer = System.Convert.FromBase64String(text); return "1F-8B-08" == BitConverter.ToString(new List<Byte>(gzBuffer).GetRange(4, 3).ToArray()); It checks the beginning of the

Parsing invalid ampersands with Android's XmlPullParsers

霸气de小男生 提交于 2019-11-28 03:34:58
问题 I am writing a little screen-scraping app that consumes some XHTML - it goes without saying that the XHTML is invalid: ampersands aren't escaped as & . I am using Android's XmlPullParser and it spews out the following error upon the incorrectly encoded value: org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:START_TAG <a href='/Fahrinfo/bin/query.bin/dox?ld=0.1&n=3&i=9c.0323581.1266265347&rt=0&vcra'> @55:134 in java.io.InputStreamReader@43b1ef70) How do I get around

Base64 String throwing invalid character error

心不动则不痛 提交于 2019-11-27 17:37:47
问题 I keep getting a Base64 invalid character error even though I shouldn't. The program takes an XML file and exports it to a document. If the user wants, it will compress the file as well. The compression works fine and returns a Base64 String which is encoded into UTF-8 and written to a file. When its time to reload the document into the program I have to check whether its compressed or not, the code is simply: byte[] gzBuffer = System.Convert.FromBase64String(text); return "1F-8B-08" ==

C# Sanitize File Name

大憨熊 提交于 2019-11-27 16:56:22
I recently have been moving a bunch of MP3s from various locations into a repository. I had been constructing the new file names using the ID3 tags (thanks, TagLib-Sharp!), and I noticed that I was getting a System.NotSupportedException : "The given path's format is not supported." This was generated by either File.Copy() or Directory.CreateDirectory() . It didn't take long to realize that my file names needed to be sanitized. So I did the obvious thing: public static string SanitizePath_(string path, char replaceChar) { string dir = Path.GetDirectoryName(path); foreach (char c in Path

Why aren't ◎ܫ◎ and ☺ valid JavaScript variable names?

给你一囗甜甜゛ 提交于 2019-11-27 09:55:48
I noticed that in Internet Explorer (but, unfortunately, not in the other browsers I tested), you can use some Unicode variable names. This made my day, and I was absolutely delighted that I could write fun Unicode-laden code like this: var ктоείναι草泥马 = "You dirty horse.", happy☺n☺mat☺p☺eia = ":)Yay!", ಠ_ಠ = "emoticon"; alert(ктоείναι草泥马 + happy☺n☺mat☺p☺eia + ಠ_ಠ); For some reason, though, ◎ܫ◎ , ♨_♨ and ☺ are not valid variable names. Why do ಠ_ಠ and 草泥马 work, but ◎ܫ◎ , ♨_♨ and ☺ don't? EDIT: Test it out in your browser on JSFiddle . I've tested it in Internet Explorer 9, Chrome, Firefox, and

Why aren't ◎ܫ◎ and ☺ valid JavaScript variable names?

不羁岁月 提交于 2019-11-27 04:01:26
问题 I noticed that in Internet Explorer (but, unfortunately, not in the other browsers I tested), you can use some Unicode variable names. This made my day, and I was absolutely delighted that I could write fun Unicode-laden code like this: var ктоείναι草泥马 = "You dirty horse.", happy☺n☺mat☺p☺eia = ":)Yay!", ಠ_ಠ = "emoticon"; alert(ктоείναι草泥马 + happy☺n☺mat☺p☺eia + ಠ_ಠ); For some reason, though, ◎ܫ◎ , ♨_♨ and ☺ are not valid variable names. Why do ಠ_ಠ and 草泥马 work, but ◎ܫ◎ , ♨_♨ and ☺ don't? EDIT:

Is there a Python library function which attempts to guess the character-encoding of some bytes? [duplicate]

风流意气都作罢 提交于 2019-11-27 02:45:06
问题 This question already has an answer here: How to determine the encoding of text? 9 answers I'm writing some mail-processing software in Python that is encountering strange bytes in header fields. I suspect this is just malformed mail; the message itself claims to be us-ascii, so I don't think there is a true encoding, but I'd like to get out a unicode string approximating the original one without throwing a UnicodeDecodeError . So, I'm looking for a function that takes a str and optionally

cin.clear() doesn't reset cin object

烈酒焚心 提交于 2019-11-26 23:23:18
问题 I have the following loop. It should read numbers until EndOfFile , or the user input -999 int arr[100]; int index; for (index = 0; index < 100; index++) { cin >> arr[index]; if (!cin) { cin.clear(); index--; continue; } if (arr[index] == -999) { break; } } When the user input an invalid thing, such as some char s, this loop is being repeated for ever without clear ing the error state or stopping. 回答1: After calling clear , you must also somehow remove the invalid input from the stream. Here

C# Sanitize File Name

不想你离开。 提交于 2019-11-26 18:46:56
问题 I recently have been moving a bunch of MP3s from various locations into a repository. I had been constructing the new file names using the ID3 tags (thanks, TagLib-Sharp!), and I noticed that I was getting a System.NotSupportedException : "The given path's format is not supported." This was generated by either File.Copy() or Directory.CreateDirectory() . It didn't take long to realize that my file names needed to be sanitized. So I did the obvious thing: public static string SanitizePath_