decode

Failed to decode downloaded font

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is an error I am getting in Chrome and unfortunately searching for it hasn't given me much results. The font itself is appearing correctly. However I still get this error/warning. More specifically, this is the full warning: "Failed to decode downloaded font: http://localhost:8000/app/fonts/Lato/ " My CSS are these: @font-face { font-family:"Lato"; src: url("../fonts/Lato/"); } html, body { font-family:'Lato'; } I just do not understand. The font is applied correctly, but the warning is always there. Trying to use Sans-Serif makes the

Decode poweshell output possibly containing non-ascii unicode characters into a python string

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to decode powershell stdout called from python into a python string. My ultimate goal is to get in a form of a list of strings the names of network adapters in Windows. My current function looks like this and works well on Windows 10 with English language: def get_interfaces(): ps = subprocess.Popen(['powershell', 'Get-NetAdapter', '|', 'select Name', '|', 'fl'], stdout = subprocess.PIPE) stdout, stdin = ps.communicate(timeout = 10) interfaces = [] for i in stdout.split(b'\r\n'): if not i.strip(): continue if i.find(b':')<0: continue

Decode escaped characters in URL

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a list containing URLs with escaped characters in them. Those characters have been set by urllib2.urlopen when it recovers the html page: http://www.sample1webpage.com/index.php?title=%E9%A6%96%E9%A1%B5&action=edit http://www.sample1webpage.com/index.php?title=%E9%A6%96%E9%A1%B5&action=history http://www.sample1webpage.com/index.php?title=%E9%A6%96%E9%A1%B5&variant=zh Is there a way to transform them back to their unescaped form in python? P.S.: The URLs are encoded in utf-8 回答1: Official docs. urllib.unquote( string ) Replace %xx

Detect bad json data in PHP json_decode()?

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying handle bad json data when parsed through json_decode(). I'm using the following script: if(!json_decode($_POST)) { echo "bad json data!"; exit; } If $_POST equals: '{ bar: "baz" }' Then json_decode handles the error fine and spits out "bad json data!"; However, if I set $_POST to something like "invalid data", it gives me: Warning: json_decode() expects parameter 1 to be string, array given in C:\server\www\myserver.dev\public_html\rivrUI\public_home\index.php on line 6 bad json data! Do I need to write a custom script to detect

How to decode encoded special XML characters in a string?

匿名 (未验证) 提交于 2019-12-03 02:00:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I was given a string like example.com/test?region=us&lang=en&jurisdiction=us How can I write the java code to decode the encoded characters like & in the string. Is there any existing class/method to decode them? Thanks. 回答1: To unescape HTML/XML entities, use Apache Commons Lang StringEscapeUtils or homegrow one . 回答2: StringEscapeUtils seems to escape everything 回答3: You can also include special characters in XPL. XPL has exactly the same structure as XML, but allows special characters. There is an XML parser with source code available for

Retrofit and OkHttp gzip decode

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The REST service I want to consume answers as a gzipped encoded JSON. It provides the Content-Encoding: gzip , but my OkHttp does not encode it to readable text, so the JSON converter throws an exception. According to Jake Whartons comment the Content-Encoding: gzip Header should tell OkHttp to decode the body. The code for creating the RestAdapter is: final RestAdapter adapter = new RestAdapter.Builder() .setEndpoint(baseUrl) .setClient(new OkClient(new OkHttpClient())) .setConverter(new GsonConverter(gson)) .setLogLevel(RestAdapter

How do I decode escaped unicode javascript code in Python?

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this string: V posledn\u00edch m\u011bs\u00edc\u00edch se bezpe\u010dnostn\u00ed situace v Libyi zna\u010dn\u011b zhor\u0161ila, o \u010dem\u017e sv\u011bd\u010d\u00ed i ned\u00e1vn\u00e9 n\u00e1hl\u00e9 opu\u0161t\u011bn\u00ed zem\u011b nejen \u010desk\u00fdmi diplomaty. Libyi hroz\u00ed nekontrolovan\u00fd rozpad a nekone\u010d Which should read "V posledních měsících se ..." so \u00ed is í and \u011b is ě. Any idea how to decode this in Python? It is a javascript code I am parsing in python. I could write my own ad-hoc solution as

How to decode Rijndael in ruby (encoded in VB.net)

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Rinjael to encode in VB.NET and need to decode in Ruby. My VB.NET encryption class looks like this: Private Class Encryptor Private symmetricKey As System.Security.Cryptography.RijndaelManaged Private iVector As Byte() Private Key As Byte() Public Function encrypt(ByVal data As String) As String Try Dim plainTextBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(data) Dim encryptor As System.Security.Cryptography.ICryptoTransform = symmetricKey.CreateEncryptor(Key, iVector) Dim memoryStream As New System.IO.MemoryStream Dim

How do I correctly decode unicode parameters passed to a servlet

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Suppose I have: Yahoo! I have confirmed external_title gets encoded as Yahoo!%E2%84%A2 and passed to SERVLET . If in SERVLET I do: Writer writer = response.getWriter(); writer.write(request.getParameter("external_title")); I get in the browser. If I manually switch the browser character encoding to UTF-8, it changes to Yahoo! TM (which is what I want). So I figured the encoding I was sending to the browser was wrong (it was Content-type: text/html; charset=ISO-8859-1 ). I changed SERVLET to: response.setContentType("text/html; charset=utf-8"

Decode Base64 data in Java

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an image that is Base64 encoded. What is the best way to decode that in Java? Hopefully using only the libraries included with Sun Java 6. 回答1: As of v6, Java SE ships with JAXB. javax.xml.bind.DatatypeConverter has static methods that make this easy. See parseBase64Binary() and printBase64Binary() . 回答2: As of Java 8 , there is an officially supported API for Base64 encoding and decoding. In time this will probably become the default choice. The API includes the class java.util.Base64 and its nested classes. It supports three