decode

Reading binary file bitwise in R

牧云@^-^@ 提交于 2019-12-24 15:26:02
问题 Since I am not a programmer I got stuck solving this probably trivial problem: I would like to extract numeric values from binary file (example.Lis) using R. First 256 bytes contain a header. I know the header structure therefore I was able to decode its content. For instance, according the format description, OLE DATE information is stored in bytes 8-15 as a double data type. To read this, I simply used following command: my.file = file("example.Lis", "rb") headall<-readBin(my.file, raw(), n

Python Unreproducible UnicodeDecodeError

匆匆过客 提交于 2019-12-24 07:52:38
问题 I'm trying to replace a substring in a Word file, using the following command sequence in Python. The code alone works perfectly fine - even with the exact same Word file, but when embedding it in a larger scale project structure, it throws an error at exact that spot. I'm clueless as to what causes it, as it seemingly has nothing to do with the code and seems unreproducible for me. Side note: I know what's causing the Error, it's a german 'ü' in the Word file, but it's needed and removing it

help to get rid of HTML special chars in database

与世无争的帅哥 提交于 2019-12-24 00:44:59
问题 I've migrated my site from interspire CMS to Joomla! CMS. I've managed to migrate all the database of articles, but some of them have a weird issue - when I access the page from joomla, the title contains HTML entities like ’ . As you can guess from the CMS's I use, I rely on PHP as my server side, and MySql for my database. I tried to go over the titles of the articles in the database with htmlspecialchars_decode AND html_entity_decode in order to get rid of those, but it had no effect. if I

Java or Scala. How to convert characters like \x22 into String

纵然是瞬间 提交于 2019-12-24 00:35:27
问题 I have a string that looks like this: {\x22documentReferer\x22:\x22http:\x5C/\x5C/pikabu.ru\x5C/freshitems.php\x22} How could I convert this into a readable JSON? I've found different slow solutions like here with regEx Have already tried: URL.decode StringEscapeUtils JSON.parse // from different libraries For example python has simple solution like decode from 'string_escape' Linked possible duplicate applies to Python, and my question is about Java or Scala Working but also very slow

PHP Receive JSON but can't decode it

筅森魡賤 提交于 2019-12-24 00:34:41
问题 I receive JSON code in PHP but if I try to decode it nothing happens. CODE: $json = stripslashes($_POST['json']); $output = json_decode($json); When I log $json and $output to the console: $json value is : {"post":"{'newfavorite':'<div id="1" class="favorite"><sub class="minID">Id 1</sub><a href="http://www.youtube.com/watch?v=1PXQpWm_kq0">http://www.youtu</a><span onclick="movefavorite(1)"><img class="move" title="Move" src="icon/move.png"></span><span onclick="removefavorite(1)"><img class=

decode部分阅读记录

空扰寡人 提交于 2019-12-23 21:43:38
图1 初始化和viterbi给结构解码 class Decoder ( object ) : def __init__ ( self , alphas , betas , steps ) : . . . . . . . . . . . . . . . . . . . . def viterbi_decode ( self ) : # 注意这里的[:2]是取前两维的意思,就是取图1中的网络框架。 prob_space = np . zeros ( ( self . network_space . shape [ : 2 ] ) ) path_space = np . zeros ( ( self . network_space . shape [ : 2 ] ) ) . astype ( 'int8' ) # 循环遍历layer层,即图1中的横向坐标。 for layer in range ( self . network_space . shape [ 0 ] ) : if layer == 0 : # 初始化prob和path的值。 prob_space [ layer ] [ 0 ] = self . network_space [ layer ] [ 0 ] [ 1 ] prob_space [ layer ] [ 1 ] = self . network_space [

Oracle Decode function results with different formats

人走茶凉 提交于 2019-12-23 18:47:37
问题 SELECT DECODE (SYSDATE, SYSDATE + 1, NULL, SYSDATE) FROM DUAL; SELECT DECODE (SYSDATE, SYSDATE + 1, TO_DATE (NULL), SYSDATE) FROM DUAL; why am i getting the results in different formats from the queries above? i am using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi 回答1: the decode function result has the datatype of the third parameter. In the first case, since no datatype is specified for NULL , the default VARCHAR2 is used. In the second case, a DATE is explicitely asked

Python3 - Cannot read docx, odt file - UnicodeDecodeError: 'utf-8' codec can't decode byte 0xea in position 10: invalid continuation byte

余生颓废 提交于 2019-12-23 16:26:05
问题 I am trying to split a large docx file into small files. For that when reading a file in python3.6 with the following code. with open('h.docx', 'r') as f: a = f.read() It throws this error. Traceback (most recent call last): File "<stdin>", line 2, in <module> File "/usr/local/lib/python3.6/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xea in position 10: invalid continuation byte h.docx

Unable to decode unicode string in Python 2.4

拜拜、爱过 提交于 2019-12-23 15:16:31
问题 This is in python 2.4. Here is my situation. I pull a string from a database, and it contains an umlauted 'o' (\xf6). At this point if I run type(value) it returns str. I then attempt to run .decode('utf-8'), and I get an error ('utf8' codec can't decode bytes in position 1-4). Really my goal here is just to successfully make type(value) return unicode. I found an earlier question that had some useful information, but the example from the picked answer doesn't seem to run for me. Is there

Python file input string: how to handle escaped unicode characters?

烈酒焚心 提交于 2019-12-23 12:37:15
问题 In a text file (test.txt), my string looks like this: Gro\u00DFbritannien Reading it, python escapes the backslash: >>> file = open('test.txt', 'r') >>> input = file.readline() >>> input 'Gro\\u00DFbritannien' How can I have this interpreted as unicode? decode() and unicode() won't do the job. The following code writes Gro\u00DFbritannien back to the file, but I want it to be Großbritannien >>> input.decode('latin-1') u'Gro\\u00DFbritannien' >>> out = codecs.open('out.txt', 'w', 'utf-8') >>>