decode

Java Reading Undecoded URL from Servlet

ぃ、小莉子 提交于 2019-12-09 06:25:31
问题 Let's presume that I have string like '=&?/;#+%' to be a part of my URL, let's say like this: example.com/servletPath/someOtherPath/myString/something.html?a=b&c=d#asdf where myString is the above string. I've encoded critical part so URL looks like example.com/servletPath/someOtherPath/%3D%26%3F%2F%3B%23%2B%25/something.html?a=b&c=d#asdf So far so good. When I'm in the servlet and I read any of request.getRequestURI() , request.getRequestURL() or request.getPathInfo() , returned value is

Missing Data with URLSession and JSONDecode in Swift4

杀马特。学长 韩版系。学妹 提交于 2019-12-09 04:32:29
Using Swift4, iOS11.1, Xcode9.1, The following parseData method almost works. Everything seems to work fine (and a correct JSON-data set is fetched by this URLSession and JSONDecode). However, what is really surprising to me is the fact that a normal Browser shows different JSON-data (i.e. 20x as much is fetched than compared to this iOS-URLSession approach). Why is that ?? In the code below, you can find two print statements. The first showing the actual URLRequest-string (including all query- and type-parameters). The second prints the number of fetched JSON data-sets. If you use a Browser

how to decode html codes using Java? [duplicate]

让人想犯罪 __ 提交于 2019-12-08 23:56:49
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Java: How to decode HTML character entities in Java like HttpUtility.HtmlDecode? I need to extract paragraphs (like title in StackOverflow) from an html file. I can use regular expressions in Java to extract the fields I need but I have to decode the fields obtained. EXAMPLE field extracted: Paging Lucene&#39s search results (with **;** among **&#39** and **s**) field after decoding: Paging Lucene's search

effective python 读书笔记:第20条-用None和文档字符串来描述具有动态默认值的参数

寵の児 提交于 2019-12-08 23:11:32
第20条-用None和文档字符串来描述具有动态默认值的参数 关键: 1 参数的默认值 特点: 包含代码的模块一旦加载进来,参数的默认值就不变了 2 动态设置默认值 把默认值设置为None,如果发现参数的值为None,就设置为默认值 先看一个示例 def log1(content, when=datetime.utcnow()): print("content: {content}, when: {when}".format(content=content, when=when)) def log2(content, when=None): """ :param content: :param when: :return: """ when = datetime.utcnow() if when is None else when print("content: {}, when: {}".format(content, when)) def process(): log1('test1') time.sleep(1) log1('test2') print('=====') log2('test1') time.sleep(1) log2('test2') if __name__ == "__main__": process() #输出 content: test1, when:

Preon decode and then encode doesn't return the same byte array

自古美人都是妖i 提交于 2019-12-08 22:50:32
I am using Preon to encode enum fields in a byte array. The fields of the first byte (example-byte: 0xf7=1111 01 11) are set up as this: @BoundNumber(size="2") //Corresponds to 11 private byte b1_1_notUsed; @BoundNumber(size="2") //Corresponds to 01 private ParkingBrakeSwitch parkingBrakeSwitch; @BoundNumber(size="4") private byte b1_3_notUsed; //Corresponds to 1111 Decoding works fine, thus I expect encoding the decoded object back to a byte array will yield the same byte array that I had from the beginning. This is not the case however. Instead the bits in the first byte are encoded like

How can I decode a quotedprintable encoded String?

▼魔方 西西 提交于 2019-12-08 21:08:50
问题 I'm writing a webmail app and need to decode Quotedprintable values in the emails header fields. I've tried several decode functions from various packages on haskell, so far without luck. How can I decode for example this string: "freelancermap Newsletter: Erfolgreich =?ISO-8859-1?Q?selbstst=E4ndig?= mit Sicherheit" 来源: https://stackoverflow.com/questions/15098452/how-can-i-decode-a-quotedprintable-encoded-string

PHP json_decode return empty array

对着背影说爱祢 提交于 2019-12-08 19:35:32
I just test this sample from php doc ( http://au2.php.net/manual/en/function.json-decode.php ) here is my code: <?php $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; echo json_decode($json, true), '<br />';?> But it just returns an EMPTY array. Have no idea why...Been searching around but no solution found. PLEASE help! you should not use echo because it is an array. use print_r or var_dump .it works fine $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}'; print_r(json_decode($json, true)); Output: Array ( [a] => 1 [b] => 2 [c] => 3 [d] => 4 [e] => 5 ) You can validate at following website: http://jsonlint

Python 读取文件编码错误

社会主义新天地 提交于 2019-12-08 19:21:08
1、UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 32: illegal multibyte sequence UnicodeDecodeError: 'gbk' codec can't decode byte 0xaa in position 132: illegal multibyte sequence 解决方案:尚未有 推测: 字符集合(   ) 问题出在“gbk"和”utf-8"都不能读取上面的那些(红色标注)字符,目前解决方法是找到文本中的这个字符,对其进行删除,再读取文本,或者使用try ……except 结构,凡是遇到读取失败的文本,continue 跳过,读取下一个文件。 2、SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: malformed \N character escape 解决方案:初步确认是文件路径的格式不对,filename应该为:E:/Python/Corpus/News/Environment/001.txt 这里是斜杆,而不是反斜杠 3、UnicodeDecodeError: 'utf-8' codec can't decode

Python 3.4 decode bytes

徘徊边缘 提交于 2019-12-08 18:44:59
问题 I am trying to write a file in python, and I can't find a way to decode a byte object before writing the file, basically, I am trying to decode this bytes string: Les \xc3\x83\xc2\xa9vad\xc3\x83\xc2\xa9s into this, which is the original text I'm trying to recover: Les évadés I tried using the .decode('utf-8') and encode('utf-8') but nothing seems to work... I always get Les évadés as a result... I am using python 3.4.3 Anyone can help? 回答1: And if you want a Python 3 solution: b = b'Les

How to encode URL in JavaScript and PHP?

一世执手 提交于 2019-12-08 09:42:01
问题 I want to send a URL in a POST request in a variable called surl . How should I encode it in JavaScript and decode it in PHP? For example, the value of surl could be http://www.google.co.in/search?q=javascript+urlencode+w3schools . EDIT Sorry, I forgot to mention, it's not form submission but a ajax request. 回答1: Use encodeURIComponent(uri) (for encoding) and decodeURIComponent(uri) for decoding, E.g (encoding). var uri="http://w3schools.com/my test.asp?name=ståle&car=saab"; document.write