unicode

Selective replacement of unicode characters in Python using regex

Selective replacement of unicode characters in Python using regex Question: There are many answers as to how one can use regex to remove unicode characters in Python. See Remove Unicode code (uxxx) in string Python and Python regex module "re" match unicode characters with u However, in my case, I don’t want to replace every …

Total answers: 2

Preserve letter order when replacing LTR chars with RTL chars in a word at byte level

Preserve letter order when replacing LTR chars with RTL chars in a word at byte level Question: I have a Hebrew word "יתꢀראꢁ" which needs to be "בראשית". To correct I am encoding and than replacing chars. The replacement works however since I am replacing LTR chars with RTL chars the order gets jumbled. data="יתꢀראꢁ".encode("unicode_escape") …

Total answers: 2

In Python, how to use re.sub() to replace all literal Unicode spaces?

In Python, how to use re.sub() to replace all literal Unicode spaces? Question: In Python, when I use readlines() to read from a text file, something that was originally a space will become a literal Unicode character, as shown follows. Where u2009 is a space in the original text file. So, I’m using re.sub() to …

Total answers: 2

Python utf-8 encoding not following unicode rules

Python utf-8 encoding not following unicode rules Question: Background: I’ve got a byte file that is encoded using unicode. However, I can’t figure out the right method to get Python to decode it to a string. Sometimes is uses 1-byte ASCII text. The majority of the time it uses 2-byte "plain latin" text, but it …

Total answers: 1

Converting elements in a single list to key/value pair using Unicode characters as key

Converting elements in a single list to key/value pair using Unicode characters as key Question: I have a list (see below) that I want to take any element in the list containing a Unicode character (e.g.,’①’,’②’,’㉖’) as the key/value pair inside a ‘category’ JSON element and the following elements in the list between each Unicode …

Total answers: 2

How to send accented characters with diacritics in HTTP request-payload?

How to send accented characters with diacritics in HTTP request-payload? Question: I am requiring to send special characters like accented characters with diacritics, e.g. o-acute ó, via API This is my test code import string import http.client import datetime import json def apiSendFarmacia(idatencion,articulo,deviceid): ##API PAYLOAD now = datetime.datetime.now() conn = http.client.HTTPSConnection("apimocha.com") payload = json.dumps({ "idatencion": …

Total answers: 1

How to print unicode character from a string variable?

How to print unicode character from a string variable? Question: I am new in programming world, and I am a bit confused. I expecting that both print result the same graphical unicode exclamation mark symbol: My experiment: number = 10071 byteStr = number.to_bytes(4, byteorder=’big’) hexStr = hex(number) uniChar = byteStr.decode(‘utf-32be’) uniStr = ‘\u’ + hexStr[2:6] …

Total answers: 1

How to combine two code points to get one?

How to combine two code points to get one? Question: I know that unicode code point for Á is U+00C1. I read on internet and many forums and articles that I can also make an Á by combining characters ´ (unicode: U+00B4) and A (unicode: U+0041). My question is simple. How to do it? I …

Total answers: 2

How to render math symbols as text in SVG/EPS/PDF images?

How to render math symbols as text in SVG/EPS/PDF images? Question: When creating graphs using, for instance, Python. It is possible to save these figures as vector graphics (SVG, EPS, PDF) and the text is rendered separately. This makes it possible to select or search the text when shown in a pdf file. However, I’ve …

Total answers: 2