decoding

Base64URL decoding via JavaScript?

ぐ巨炮叔叔 提交于 2019-12-10 02:04:20
问题 So I'm stumped. I know there's lots of Base64 encoders/decoders for JS, but not for the modified (and Facebook-favored) Base64URL variation. So far searching across stackoverflow has come up dry. Yes, I could use PHP or another server-side library to decode this, but I'm trying to keep this universal regardless of what platform I'm using... for example, if I were to host a HTML-only Facebook app on Amazon S3/CloudFront and only use their JS SDK and jQuery to take care of processing forms and

UTF-8 Decode for php

一世执手 提交于 2019-12-09 23:05:52
问题 I am fetching posts from the Tumblr API and am running into an encoding issue with the returned "body" of the "post". All apostrophes are replaced by something that looks like "aETM". I am trying to use: utf8_decode($string) But all that does is replace the occurrences of "aETM" with a "?". Any suggestions? 回答1: try $string = mb_convert_encoding($string,'HTML-ENTITIES','utf-8'); 回答2: Use this link to convert string iconv("UTF-8", "CP1252", $data) 来源: https://stackoverflow.com/questions

QString in Persian

岁酱吖の 提交于 2019-12-09 16:09:45
问题 I have given a Qt Project which needs to support Persian language.T he data is sent from a server and using the first line, I get a QByteArray and convert it to QString using the second line: QByteArray readData = socket->readAll(); QString DataAsString = QTextCodec::codecForUtfText(readData)->toUnicode(readData); When the data is sent is English, everything is fine, but when it is Persian, instead of سلام I get سÙ\u0084اÙ\u0085 I mentioned the process so people wouldn't suggest methods to

Why does chardet say my UTF-8-encoded string (originally decoded from ISO-8859-1) is ASCII?

只愿长相守 提交于 2019-12-09 12:26:30
问题 I'm trying to convert ascii characters to utf-8. This little example below still returns ascii characters: chunk = chunk.decode('ISO-8859-1').encode('UTF-8') print chardet.detect(chunk[0:2000]) It returns: {'confidence': 1.0, 'encoding': 'ascii'} How come? 回答1: Quoting from Python's documentation: UTF-8 has several convenient properties: It can handle any Unicode code point. A Unicode string is turned into a string of bytes containing no embedded zero bytes. This avoids byte-ordering issues,

How to use base64 classes?

為{幸葍}努か 提交于 2019-12-09 07:55:40
问题 I want get the image from an xml file which is encoded using base64. I want to decode that data into image, but i don't know how to do that. So please give me some instructions to find that... 回答1: There's a nice code sample at the bottom of this post. Very self-contained... http://www.cocoadev.com/index.pl?BaseSixtyFour for more read SO post 来源: https://stackoverflow.com/questions/5429680/how-to-use-base64-classes

UnicodeDecodeError: 'utf8' codec can't decode byte 0xc3 in position 34: unexpected end of data

强颜欢笑 提交于 2019-12-08 19:42:43
问题 I'm trying to write a scrapper, but I'm having issues with encoding. When I tried to copy the string I was looking for into my text file, python2.7 told me it didn't recognize the encoding, despite no special characters. Don't know if that's useful info. My code looks like this: from urllib import FancyURLopener import os class MyOpener(FancyURLopener): #spoofs a real browser on Window version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11' print

How to deal with cv::VideoCapture decode errors?

旧街凉风 提交于 2019-12-08 15:35:15
问题 I'm streaming H264 content from an IP camera using the VideoCapture from OpenCV (compiled with ffmpeg support). So far things work ok, but every once in a while I get decoding errors (from ffmpeg I presume): [h264 @ 0x103006400] mb_type 137 in I slice too large at 26 10 [h264 @ 0x103006400] error while decoding MB 26 10 [h264 @ 0x103006400] negative number of zero coeffs at 25 5 [h264 @ 0x103006400] error while decoding MB 25 5 [h264 @ 0x103006400] cbp too large (421) at 35 13 [h264 @

Android how to increase ffmpeg mp4 perfromance?

99封情书 提交于 2019-12-08 11:21:10
问题 I have detected that function avcodec_decode_audio3 works slow with mp4 format, here my code cycle for decoding audio: while (av_read_frame(av_format_context, &packet) >= 0 && is_play == 1) { if (av_codec_context->codec_type == AVMEDIA_TYPE_AUDIO && is_play == 1) { int out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; int size = packet.size; int n; int dataLength = size; int decoded = 0; while (size > 0) { //start measure time gettimeofday(&tvBegin, NULL); int len = avcodec_decode_audio3(av_codec

handle non ascii code string in python

穿精又带淫゛_ 提交于 2019-12-08 06:09:39
问题 It is really confusing to handle non-ascii code char in python. Can any one explain? I'm trying to read a plain text file and replace all non-alphabetic characters with spaces. I have a list of characters: ignorelist = ('!', '-', '_', '(', ')', ',', '.', ':', ';', '"', '\'', '?', '#', '@', '$', '^', '&', '*', '+', '=', '{', '}', '[', ']', '\\', '|', '<', '>', '/', u'—') for each token i got, i replace any char in that token with space by calling for punc in ignorelist: token = token.replace

Converting BinHex file to normal file using Java [closed]

折月煮酒 提交于 2019-12-07 15:09:59
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . 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