encoding

How to create a GSM-7 encoding in Python?

巧了我就是萌 提交于 2020-01-06 03:18:07
问题 The GSM-7 character set is defined as a basic mapping table + an extension character mapping table (https://en.wikipedia.org/wiki/GSM_03.38#GSM_7-bit_default_alphabet_and_extension_table_of_3GPP_TS_23.038_.2F_GSM_03.38). Meaning that u'@' should be mapped to b'\x00' (a byte string of length 1), but u'[' should be mapped to b'\x1b<' or b'\x1b\x3c' (a byte string of length 2). I've managed to get the encoding part to work by extending the encoding_table , but I'm not sure what to do that with

Is it possible to prevent adding BOM to output UTF-8 file? (Visual Studio 2005)

半城伤御伤魂 提交于 2020-01-06 03:16:06
问题 I need some help. I'm writing a program that opens 2 source files in UTF-8 encoding without BOM. The first contains English text and some other information, including ID. The second contains only string ID and translation. The program changes every string from the first file by replacing English chars to Russian translation from the second one and writes these strings to output file. Everything seems to be ok, but there is BOM appears in destination file. And i want to create file without BOM

Problem encrypting/encoding URL variable

陌路散爱 提交于 2020-01-06 03:03:11
问题 I have a class that takes a string in this format: 000067000000000012620060324b38e2cab3353 , encrypts the string then appends it as a get variable in a URL. The class that does the encryption has a function that looks like this: private function _code_encryption($enc_type,$a_string){ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); if($enc_type == self::ENCRYPT_STRING){ //encrypt then return base64 encoded $encrypted = mcrypt

Fixtures: How to load utf-8 characters and convert to non utf-8 and save into database?

匆匆过客 提交于 2020-01-06 01:16:07
问题 I am new to Rails. I am working on a legacy code which relies on Fixtures to load non UTF8 characters from yml files into database. With rails lastest version, the yml must be utf-8 encoding, meaning that what Fixtures read in will be utf-8 encoding. How to convert the following codes so that it will convert from utf-8 to non-utf8 and load into database (non-utf8 encoding of course). class LoadUsersData < ActiveRecord::Migration def self.up down directory = File.join(File.dirname(__FILE__))

Unable to encode to iso-8859-1 encoding for some chars using Perl Encode module

烂漫一生 提交于 2020-01-05 17:31:21
问题 I have a HTML string in ISO-8859-1 encoding. I need to pass this string to HTML:Entities::decode_entities() for converting some of the HTML ASCII codes to respective chars. To so i am using a module HTML::Parser::Entities 3.65 but after decode_entities() operation my whole string changes to utf-8 string. This behavior seems fine as the documentation of the HTML::Parse. As i need this string back in ISO-8859-1 format for further processing so i have used Encode::encode("iso-8859-1",$str) to

Encoding error in Django on Heroku

老子叫甜甜 提交于 2020-01-05 17:30:34
问题 I see some topics where people say to use this command to solve the problem heroku config:add LANG=en_US.UTF-8 I did it already but keep getting encoding problem, like this UnicodeEncodeError at /admin/controladoria/orgao/2/ 'ascii' codec can't encode character u'\xe7' in position 23: ordinal not in range(128) if I try to run the command above it is what I got.... daniel@daniel-VirtualBox: (dev *) $ heroku config:add LANG=en_US.UTF-8 Setting config vars and restarting rocky-hollows-8072...

TSQL FOR XML Exporting ACTUAL UTF-8 Encoded data

て烟熏妆下的殇ゞ 提交于 2020-01-05 14:54:26
问题 We have a process that writes XML (Using SQL's FOR XML). When it was executed via SQLCMD in a batch file the output was in UTF-8 format (specifically 8-bit ascii characters become 2 byte). When I do the same thing through Execute SQL Command in SSIS it's not UTF-8 encoded. Here's a simple example. The ® should become 2 bytes: SELECT 'Diversity® Certified' as fldAgentLastName FOR XML PATH('agent'), ELEMENTS, TYPE, ROOT('agents') The output is: Diversity® Certified it SHOULD be: Diversity®

Who's responsible for this wrong encoding?

六月ゝ 毕业季﹏ 提交于 2020-01-05 12:58:13
问题 I have a HTML file with a javascript. The javascript reads a local ISO-8859-1 CSV file through AJAX. I have declared three times that I'm working with ISO-8859-1, and still the rendering is wrong, showing that black square with a '?' inside. What am I doing wrong? I don't know what else to try... Not sure if this is important, but the text I am trying to print show is the title in a google.maps.Marker . Maybe it HAS to be utf-8? Maybe there's no way but to convert the string to UTF-8 first?

Weird characters after processing a xml file in android

笑着哭i 提交于 2020-01-05 10:33:34
问题 I am making an andorid applicaiton which loads data from a xml file. The problem is that the xml file is not processed correctly and I am not able to serialize it, because of that. I think the problem is related to the encoding of the file. How I made the xml file? From Eclipse I have clicked on New-> File -> and created a blank xml, then I've filled it with the needed information. Here is how the xml looks in the editor: <?xml version="1.0" encoding="UTF-8"?> <data> <categories> <category

Weird characters after processing a xml file in android

假装没事ソ 提交于 2020-01-05 10:33:07
问题 I am making an andorid applicaiton which loads data from a xml file. The problem is that the xml file is not processed correctly and I am not able to serialize it, because of that. I think the problem is related to the encoding of the file. How I made the xml file? From Eclipse I have clicked on New-> File -> and created a blank xml, then I've filled it with the needed information. Here is how the xml looks in the editor: <?xml version="1.0" encoding="UTF-8"?> <data> <categories> <category