-
전각문자(full-width) 로 변경 코드Dev Language/Python 2022. 4. 18. 20:37
def convert_full_witdh_char(line) : """ Converts characters to full-width characters Args: line(string) : mixed characters(half-width, full-width)) Return: string : only full-width characters exist """ def convert(x): unicode_x = ord(x) if 0x21 <= unicode_x <=0x7E: # [A-Za-z0-9!"#$%&'()*+,./:;<=>?@\^_`{|}~-] return chr(unicode_x + 0XFEE0) elif unicode_x == 0x20: ## space return chr(0x3000) else: return x full_width_ch = [convert(x) for x in line] return ''.join(full_width_ch)