All Questions
Tagged with python-2.7 utf-8
360
questions
0
votes
1
answer
97
views
python2.7 - How to decode JSON without decoding the UTF-8 inside of it?
I need a function to decode UTF-8 encoded JSON. This function should take a UTF-8 encoded JSON string and convert it to UTF-8 encoded objects. The following code works:
# helper function
def ...
1
vote
1
answer
69
views
Python json.dumps of a tuple with some UTF-8 characters, either fails or converts them. I want the encoded character retained as is
On my server, a Python script gets data from a database as a tuple. Then the script converts the tuple to a string (using json.dumps()) to be passed to the JavaScript script in the user's browser.
The ...
0
votes
1
answer
66
views
How to use UTF-8 encoding for unicode objects in python correctly
In one of the python module, there is this name string that contains non-ascii characters. While logging this object, python gives UnicodeDecodeError. For example:
# coding: UTF-8
import logging
...
2
votes
0
answers
710
views
b64decode python vs Buffer.from(ePayload, 'base64') node JS
Encryption is done is python & decryption to be done in Node js but facing following issues in JS
I guess some characters are getting escape from string within JS like 'backslash', '_', ''
...
3
votes
1
answer
1k
views
Writing hex string into a binary file
I am trying to write an hex string into a file using python 2.7 so that when opened with HxD I can retrieve the same hex values.
The following code works fine on multiple input strings, but when the ...
1
vote
1
answer
171
views
Fixing greek letters in dataframe - Python 2.7
I'm using python 2.7 and I have a dataframe with greek letters writen like this:
units = ['Ab_alpha_cd', 'XY_beta_zz', 'Ef_gamma_gh']
descriptions = ['Name1 (Ab_alpha_cd): description_1', 'Name2 (...
2
votes
1
answer
361
views
How to encrypt and decrypt the data through this AES 256 algo in this (0xe4, 0x56, 0x45) form.. it is made from unicode\utf-8 by replacing \x with 0x
this is AAES256 algo how to change its code to print the encryptoin in > {0xe8, 0x45} form
I want result in this {0x38, 0x67} form
BLOCK_SIZE = 16
pad = lambda s: s + (BLOCK_SIZE - len(s) % ...
0
votes
1
answer
169
views
Struggling to understand Python Output (Unicode, UTF-8, different Python Versions)
Environment setup
I'm using iTerm2 with default encoding UTF-8.
1/ Confusion
Starting Python2.7 Interpreter, I don't understand why we see two different outputs for seemingly the same functionality:
&...
0
votes
1
answer
687
views
How to validate that a string is a valid UTF-8 string in python 2.7
I have the following string -
"\xed\xad\x80\xed\xb1\x93"
When using this string to execute queries in the PostgreSQL DB, it raises the following error -
DataError: invalid byte sequence ...
0
votes
0
answers
60
views
Remove possible double encoding from Unicode
I am using a Python 2.7 based API to connect to a third party software. Some of the methods return broken UTF-8 encoding. I don't believe it's related to Python 2.7 handling of Unicode on my end ...
0
votes
2
answers
465
views
Python UTF8 encoding 2.7.5 / 3.8.5
What I try to understand is i'm runing Python 3.8.5 on Windows and Python 2.7.5 on my webserver.
i'm trying to translate from a JSON with a code like this
hash = ""
try:
hash = str(...
0
votes
0
answers
22
views
Parsing input using the python2.7 argsparse with other Language support
# -*- coding: utf-8 -*-
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("name", help="Enter the name")
args = parser.parse_args()
name = args.name
print name
Command:
...
0
votes
0
answers
277
views
generate only valid utf-8 character string python 2
I am trying to generate a valid utf-8 character string using python 2.
def validate_mychar(cd_rng):
return unichr(cd_rng)
def get_utf8_char():
while True:
cd_rng = random.randint(...
1
vote
1
answer
1k
views
Python2: what do str.encode() and unicode.decode() do?
From this question and its answers Python str vs unicode types I understood that unicode.encode() gives you str and str.decode() gives you unicode:
a = 'à'
ua = u'à'
print type(a) # str
print type(...
-1
votes
2
answers
401
views
How to recover symbols from utf-8
Encoding in Python 2.7 is very hard to understand. Can someone explain to me how get these string's symbols?
Here is my unicode string:
my_str = u'MFADCINEMve000301119 FACTURE EFAD CIN\u2019troD+...