decode

Convert � � to Emoji in HTML using PHP

假装没事ソ 提交于 2019-11-28 01:16:08
We have a bunch of surrogate pair (or 2-byte utf8?) characters such as �� which is the prayer hands emojis stored as UTF8 as 2 characters. When rendered in a browser this string renders as two ?? example: I need to convert those to the hands emjoi using php but I simply cannot find a combination of iconv, utf8_decode, html_entity_decode etc to pull it off. This site converts the �� properly: http://www.convertstring.com/EncodeDecode/HtmlDecode Paste in there the following string Please join me in this prayer. ��❤️ You will notice the surragate pair ( &

Parsing Email Body with 7BIT Content-Transfer-Encoding - PHP

百般思念 提交于 2019-11-28 01:02:12
问题 I've been implementing some PHP/IMAP-based email handling functionality lately, and have most everything working great, except for message body decoding (in some circumstances). I think that, by now, I've half-memorized RFC 2822 (the 'Internet Message Format' document guidelines), read through email-handling code for half a dozen open source CMSes, and read a bajillion forum posts, blog posts, etc. dealing with handling email in PHP. I've also forked and completely rewritten a class for PHP,

A way of getting a corresponding hex colour code given a Color object in Java?

戏子无情 提交于 2019-11-28 00:03:51
问题 I've inspected the Java class documentation for Color and found that I can generate a Color object from a hex code string (e.g. "#FFFFFF") using the Color.decode(); method. I would like to implement the reverse process for a project I am working on, but there doesn't seem to be a method already built in to the class for this. Is there an easy way to do this? 回答1: String.format("#%06x", color.getRGB() & 0x00FFFFFF) The masking is used for removing the alpha component, in bits 24-31 回答2: Color

Convert formatted HTML text string to NSString parts

二次信任 提交于 2019-11-27 20:42:29
I want to decode HTML string and store it in NSString. following is the html string for one of the response from google direction api. teststring is Turn <b>right</b> onto <b>Kennington Park Rd/A3</b><div style="font-size:0.9em">Continue to follow A3</div><div style="font-size:0.9em">Entering toll zone in 1.7 km at Newington Causeway/A3</div><div style="font-size:0.9em">Go through 2 roundabouts</div> I want to store this html string in Array of 4 different NSStrings with following 4 NSStrings (removing all information for size colour) Turn right onto Kennington Park Rd/A3 Continue to follow A3

Best way to handle email parsing/decoding in PHP?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 20:29:37
Currently I'm using the PEAR library's mimeDecode.php for parsing incoming emails. It seems to have a lot of issues and fails to decode a lot of messages, so I'd like to replace it with something better. I'm looking for something that is able to properly separate parts of the message, such as to, from, body, etc. Ideally it would be able to handle all common encoding methods such as base64, uuencode, quoted printable, etc. In situations where both plain text and html versions of the same message are contained in a single email, I would ideally like it to know the difference between them so I

How to decode huffman code quickly?

断了今生、忘了曾经 提交于 2019-11-27 20:20:23
问题 I have implementated a simple compressor using pure huffman code under Windows.But I do not know much about how to decode the compressed file quickly,my bad algorithm is: Enumerate all the huffman code in the code table then compare it with the bits in the compressed file.It turns out horrible result:decompressing 3MB file would need 6 hours. Could you provide a much more efficient algorithm?Should I use Hash or something? Update : I have implementated the decoder with state table,based on my

详解 python 中文编码与处理

岁酱吖の 提交于 2019-11-27 20:13:56
注意:本文只是针对 python 2,在 python 3 中,编码方式与处理技巧有些许变化,具体请参考: Python 2 与 Python 3 的差异对比: http://my.oschina.net/leejun2005/blog/173553 一、使用中文字符 在python源码中如果使用了中文字符,运行时会有错误,解决的办法是在源码的开头部分加入字符编码的声明,下面是一个例子: #!/usr/bin/env python # -*- coding: cp936 -*- Python Tutorial中指出,python的源文件可以编码ASCII以外的字符集,最好的做法是在#!行后面用一个特殊的注释行来定义字符集: # -*- coding: encoding -*- 根据这个声明,Python会尝试将文件中的字符编码转为encoding编码,并且,它尽可能的将指定地编码直接写成Unicode文本。 注意,coding:encoding只是告诉Python文件使用了encoding格式的编码,但是编辑器可能会以自己的方式存储.py文件,因此最后文件保存的时候还需要编码中选指定的ecoding才行。 二、中文字符的存储 >>> str = u"中文" >>> str u'\xd6\xd0\xce\xc4' >>> str = "中文" >>> str '\xd6\xd0

Decoding double encoded utf8 in Python

你。 提交于 2019-11-27 19:46:10
I've got a problem with strings that I get from one of my clients over xmlrpc. He sends me utf8 strings that are encoded twice :( so when I get them in python I have an unicode object that has to be decoded one more time, but obviously python doesn't allow that. I've noticed my client however I need to do quick workaround for now before he fixes it. Raw string from tcp dump: <string>Rafa\xc3\x85\xc2\x82</string> this is converted into: u'Rafa\xc5\x82' The best we get is: eval(repr(u'Rafa\xc5\x82')[1:]).decode("utf8") This results in correct string which is: u'Rafa\u0142' this works however is

Decoding qr code from image stored on the phone with Zxing (on Android phone)

杀马特。学长 韩版系。学妹 提交于 2019-11-27 19:33:39
I have an app that receives qr code from the server. I want to decode it (not with intent and camera) and display the text it contains in my app. I have alredy done this in Java SE with jars from zxing with this code: private class QRCodeDecoder { public String decode(File imageFile) { BufferedImage image; try { image = ImageIO.read(imageFile); } catch (IOException e1) { return "io outch"; } // creating luminance source LuminanceSource lumSource = new BufferedImageLuminanceSource(image); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(lumSource)); // barcode decoding QRCodeReader

Python - Encoding string - Swedish Letters

一笑奈何 提交于 2019-11-27 19:26:52
问题 I'm having some trouble with Python's raw_input command (Python2.6), For some reason, the raw_input does not get the converted string that swedify() produces and this giving me a encoding error which i'm aware of, that's why i made swedify() to begin with. Here's what i'm trying to do: elif cmd in ('help', 'hjälp', 'info'): buffert += 'Just nu är programmet relativt begränsat,\nDe funktioner du har att använda är:\n' buffert += ' * historik :: skriver ut all din historik\n' buffert += ' *