encoding

String to binary output in Java

情到浓时终转凉″ 提交于 2019-12-30 03:09:11
问题 I want to get binary (011001..) from a String but instead i get [B@addbf1 , there must be an easy transformation to do this but I don't see it. public static String toBin(String info){ byte[] infoBin = null; try { infoBin = info.getBytes( "UTF-8" ); System.out.println("infoBin: "+infoBin); } catch (Exception e){ System.out.println(e.toString()); } return infoBin.toString(); } Here i get infoBin: [B@addbf1 and I would like infoBin: 01001... Any help would be appreciated, thanks! 回答1: Only

PHP Regex validate letters and Spanish accent

我的梦境 提交于 2019-12-30 02:24:49
问题 How can I add/improvised my code so Spanish accent will be considered as valid in addition to normal alphabet (a-z) I have the following in my code public static function IsAlpha($s){ $reg = "#[^a-z\s-]#i"; $count = preg_match($reg, $s, $matches); return $count == 0; } 回答1: As found in the answer to this question, you could match accented characters using the full Letter Unicode property \p{L} . That includes regular a-z characters along with accented ones, so replace a-z in your expression

Python UTF-8 Lowercase Turkish Specific Letter

给你一囗甜甜゛ 提交于 2019-12-30 02:20:36
问题 with using python 2.7: >myCity = 'Isparta' >myCity.lower() >'isparta' #-should be- >'ısparta' tried some decoding, (like, myCity.decode("utf-8").lower()) but could not find how to do it. how can lower this kinds of letters? ('I' > 'ı', 'İ' > 'i' etc) EDIT: In Turkish, lower case of 'I' is 'ı'. Upper case of 'i' is 'İ' 回答1: Some have suggested using the tr_TR.utf8 locale. At least on Ubuntu, perhaps related to this bug, setting this locale does not produce the desired result: import locale

PHP - Convert Special Characters to HTML Entities

只谈情不闲聊 提交于 2019-12-29 09:19:11
问题 I have a problem with sending emails. If it contains special characters, it won't send. I want to convert the special characters to HTML entities like this: " ==> " & ==> & € ==> € < ==> < .... How can I do this? Thanks. 回答1: htmlentities() is what you're looking for: http://uk3.php.net/manual/en/function.htmlentities.php 回答2: You are probably looking for htmlentities() 回答3: htmlentities() does this. Use it like this: $text = htmlentities($text); But this should not be necessary if you

Firefox and UTF-16 encoding

痞子三分冷 提交于 2019-12-29 08:51:43
问题 I'm building a website with the encoding UTF-16. It means that every files (html,jsp) is encoded in UTF-18 and I set in the head of every HTML page : <meta http-equiv="content-type" content="text/html; charset=UTF-16"> My index page is correctly displayed by Chrom and IE. However, firefox doesn't render the index. It displays 2 strange characters and the full index page code : ��<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-16"> ... Do you know

“unexpected INCOMPLETE_STRING” error when printing Chinese word

时光毁灭记忆、已成空白 提交于 2019-12-29 08:51:34
问题 I tried to run a simple command in R, as a script, like this one print("寛") And R gives me an error like this: Error in source(con, echo = echo, print.eval = print.eval, max.deparse.length = max.deparse.length, : con:2:7: unexpected INCOMPLETE_STRING I guess this is some kind of encoding issue, and that Chinese word is exactly what I need to use in R. What can I do? 来源: https://stackoverflow.com/questions/8889262/unexpected-incomplete-string-error-when-printing-chinese-word

“unexpected INCOMPLETE_STRING” error when printing Chinese word

不羁岁月 提交于 2019-12-29 08:51:06
问题 I tried to run a simple command in R, as a script, like this one print("寛") And R gives me an error like this: Error in source(con, echo = echo, print.eval = print.eval, max.deparse.length = max.deparse.length, : con:2:7: unexpected INCOMPLETE_STRING I guess this is some kind of encoding issue, and that Chinese word is exactly what I need to use in R. What can I do? 来源: https://stackoverflow.com/questions/8889262/unexpected-incomplete-string-error-when-printing-chinese-word

file.encoding has no effect, LC_ALL environment variable does it

大憨熊 提交于 2019-12-29 08:39:05
问题 In the following Java program running in Linux using OpenJDK 1.6.0_22 I simply list the contents of the directory taken in as parameter at the command line. The directory contains the files which have file names in UTF-8 (e.g. Hindi, Mandarin, German etc.). import java.io.*; class ListDir { public static void main(String[] args) throws Exception { //System.setProperty("file.encoding", "en_US.UTF-8"); System.out.println(System.getProperty("file.encoding")); File f = new File(args[0]); for

Soap - base64binary data in PHP

蹲街弑〆低调 提交于 2019-12-29 08:33:12
问题 I have a SOAP client in PHP that makes calls to a WSDL service. One of the functions returns a base64binary data. I've been trying to decode it without any luck. base64_decode($encoded_base64data) will not work. I tried using base_convert() and mv_convert_encoding() with various parameters, but could not get a proper result. The encoded result data starts with: ��`I�%&/m�{J�J��t��`$ؐ@�������iG#)�*��eVe]f@�흼��{����{����;�N'���?\fdl��J�ɞ!���?~|?" (the data is much longer, this is just a small

Hack Jinja2 to encode from `utf-8` instead of `ascii`?

≡放荡痞女 提交于 2019-12-29 08:18:23
问题 Jinja2 converts all template variables into unicode before processing. Can anybody find a place where does this happen? The problem is that it assumes that strings are ascii , but we (at Roundup) are using utf-8 internally and our ORM (HyperDB) restores object properties to utf-8 automatically, and converting them all into unicode in every view just before passing to templates is too much legwork. 回答1: Answer from Armin: Unfortunately that is impossible. Jinja uses the default string coercion