Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert circled numbers to numbers ? (① to 1)

I would like to convert numbers from a string I receive after an OCR recognition over Japanese text.

For example, when I extract a date:

③① 年 ⑫ 月 ①③ 日

I would like to convert it to:

31 年 12 月 13 日

What would be the best way to achieve it ?

like image 670
Jonathan Muller Avatar asked Feb 21 '19 03:02

Jonathan Muller


People also ask

How do I type a number in a circle in Excel?

Right-click on the cell, click on Format Cell, Alignment and select Center for both Horizontal and Vertical. On the "ribbon" (toolbar), click on Insert, Shapes and select the oval. (You can drag the corners to make it a circle per se.)

How do you get the numbers in a circle on Iphone?

When you double-click the shaded circle above, immediately following a number entry, it will enclose the number (or any character) in a circle. Also, its neighbor is the combining enclosing circle backslash.

How do you type a circled number on a Mac?

In Word for Mac, use the Edit>Emoji & Symbols utility built into macOS. After opening it, click on the menu icon in the upper right corner to expand the dialog. Type circle into the Search field and you should see several types of circled numbers appear in the central display. Was this reply helpful?


1 Answers

I would use unicodedata

import unicodedata
print(unicodedata.normalize("NFKC","③① 年 ⑫ 月 ①③ 日"))

The result is this,

31 年 12 月 13 日

This also converts other variation of Japanese digits, full-width digits.

import unicodedata
print(unicodedata.normalize("NFKC","123①②③123"))

to

123123123
like image 120
akky Avatar answered Sep 20 '22 06:09

akky