decoding

EncodeError with \\xa3 (pound sign)

笑着哭i 提交于 2019-12-07 09:15:30
I'm trying to get some data from a web page. This webpage has stated that charset is utf-8. But there is a problem with \xa3 sign. I can't be encoded or decoded into/from 'utf-8'. for key,value in self.__dict__.iteritems(): if key not in self.db_attributes: print repr(value) attrs_statement+=str(key)+', ' values_statement+=str(value)+', ' ERROR: u'\xa3410' Traceback (most recent call last): File "C:\Users\Milano\My Documents\LiClipse Workspace\Velvet_scraper\vehicle.py", line 432, in <module> v.prepare_insert_statement('motorhog_temp') File "C:\Users\Milano\My Documents\LiClipse Workspace

Buffer error in avcodec_decode_audio4()

余生颓废 提交于 2019-12-07 04:44:35
问题 I have upgraded my ffmpeg version to the latest commit and Now I can see that the audio decoding funciton avcodec_decode_audio3 has been deprecated and when I use the new function avcodec_decode_audio4 , as per the changes required in it, I get the error as [amrnb @ 003a5000] get_buffer() failed. I am not able to find what causes this error. Anyone has a sample example of usng this new function: avcodec_decode_audio4((AVCodecContext *avctx, AVFrame *frame,int *got_frame_ptr, AVPacket *avpkt);

Java - How to decode a Base64 encoded Certificate

跟風遠走 提交于 2019-12-07 03:19:49
问题 Below is my requirement: Program will have an xml file as input with 3 tags: , and . All these data are Base64 encoded. Note: Program is using BC jars Program needs to decode them and verify the data for its authenticity using the signature and certificate Verified data should be Base64 decoded and written into another file Below is my code which tries to decode the certificate: public void executeTask(InputStream arg0, OutputStream arg1) throws SomeException{ try{ BufferedReader br = null;

In ActionScript 3, how to decode from xml to ActionScript class?

喜欢而已 提交于 2019-12-06 13:53:37
问题 In ActionScript 3, how to decode from xml to ActionScript class ? I could encode from ActionScript class to xml by using XmlEncoder. The xml schema I used at that time is this. [schema1.xsd] <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="user"> <xs:sequence> <xs:element name="id" type="xs:string" minOccurs="0"/> <xs:element name="password" type="xs:string" minOccurs="0"/> <xs:element name=

Base64 encoding issue in Python

强颜欢笑 提交于 2019-12-06 10:48:57
I need to save a params file in python and this params file contains some parameters that I won't leave on plain text, so I codify the entire file to base64 (I know that this isn't the most secure encoding of the world but it works for the kind of data that I need to use). With the encoding, everything works well. I encode the content of my file (a simply txt with a proper extension) and save the file. The problem comes with the decode. I print the text coded before save the file and the text coded from the file saved and there are exactly the same, but for a reason I don't know, the decode of

C# - Create own Encoding for Roman8 charset

你。 提交于 2019-12-06 06:51:22
The Roman8 charset is not supported by C#, but I need to use it properly (Encoding / Decoding strings), so I want to know what is the best method to create my own Encoding in order to support this Encoding? Is that enough : class Roman8Encoding : Encoding What about Encoder ? Decoder ? EncoderFallback ? DecoderFallback ? Any explanation on how do the job correctly is welcome. Thanks ! Jon Skeet I don't have time to give details at the moment, but I created an Encoding implementation for EBCDIC . You could use that source code as a starting point. I wrote it a long time ago, so I would probably

decode-encode UTF-8 doesn't lead to the original unicode

痴心易碎 提交于 2019-12-06 06:32:32
When I am trying to separate two Unicode characters by decoding and encoding them again I do not get the same Unicode in return but I get a different one. Attached are the responses when I try to do so. >>> s ='\xf0\x9f\x93\xb1\xf0\x9f\x9a\xac' >>> u = s.decode("utf-8") >>> u u'\U0001f4f1\U0001f6ac' >>> u[0].encode("utf-8") '\xed\xa0\xbd' >>> u[1].encode("utf-8") '\xed\xb3\xb1' >>> u[0] u'\ud83d' >>> u[1] u'\udcf1' Your version of python is using UCS-2 (16 bits per character) but these particular unicode characters require 32 bits, so element of u represents "half" of a character. u.encode(

Encode/decode a long to a string using a fixed set of letters in Java

杀马特。学长 韩版系。学妹 提交于 2019-12-06 05:13:43
问题 Given an arbitrary set of letters String range = "0123456789abcdefghijklmnopABCD#"; I am looking for 2 methods to encode/decode from long <-> String String s = encode( range, l ); and long l = decode( range, s ); So decode(range, encode(range, 123456789L)) == 123456789L And if range is "0123456789" thats the usual way of encoding. 回答1: The following code does what you need: static long decode(String s, String symbols) { final int B = symbols.length(); long num = 0; for (char ch : s

convert 16 bit grayscale DICOM image to 8 bit: the correct procedure

和自甴很熟 提交于 2019-12-06 00:32:13
I have been trying to create an image viewer for DICOM image. My program reads all the 8 bit colour and grayscale image almost correctly. But when I try to open a 16 bit image using the first 8 bits of the image, some parts are missing (pixels which uses 16 bit will be shown as dark instead of whilte). I don't really know how to use the window centre, window width, rescale slop and intercept. Please help me by giving the exact steps to convert 16 bit image to 8 bit image. Also I don't need to view the files which uses any compression technique to store the pixels. Thanks in advance. About

Converting BinHex file to normal file using Java [closed]

試著忘記壹切 提交于 2019-12-05 22:30:24
I have a binhex file. This file should be converted to normal readable file using java code. I found a similar question here, Binhex decoding using java code But the answer is not working. I tried Base64, the file is converted to some other format which is not human readable. Please help me to resolve this issue. The code i tried is as below File f = new File("Sample.pdf"); Base64 base64 = new Base64(); byte[] b = base64.decode(getBytesFromFile(f)); FileOutputStream fos = new FileOutputStream("Dcode.pdf"); fos.write(b); fos.close(); public static byte[] getBytesFromFile(File file) throws