Commit df1b8f59 authored by myhloli's avatar myhloli
Browse files

refactor(ocr_mkcontent): optimize full-width character handling

- Update condition to only convert full-width letters and numbers
- Remove separate case for full-width space
parent 2629cadc
...@@ -138,12 +138,9 @@ def full_to_half(text: str) -> str: ...@@ -138,12 +138,9 @@ def full_to_half(text: str) -> str:
result = [] result = []
for char in text: for char in text:
code = ord(char) code = ord(char)
# Full-width ASCII variants (FF01-FF5E) # Full-width letters and numbers (FF21-FF3A for A-Z, FF41-FF5A for a-z, FF10-FF19 for 0-9)
if 0xFF01 <= code <= 0xFF5E: if (0xFF21 <= code <= 0xFF3A) or (0xFF41 <= code <= 0xFF5A) or (0xFF10 <= code <= 0xFF19):
result.append(chr(code - 0xFEE0)) # Shift to ASCII range result.append(chr(code - 0xFEE0)) # Shift to ASCII range
# Full-width space
elif code == 0x3000:
result.append(' ')
else: else:
result.append(char) result.append(char)
return ''.join(result) return ''.join(result)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment