Commit f8436527 authored by Yusei Tahara's avatar Yusei Tahara

Convert fullwidth number to halfwidth ascii number.

parent 3b81f190
...@@ -8,6 +8,7 @@ from urllib import urlopen ...@@ -8,6 +8,7 @@ from urllib import urlopen
from urlparse import urljoin from urlparse import urljoin
from Errors import ValidationError from Errors import ValidationError
from DateTime.DateTime import DateError, TimeError from DateTime.DateTime import DateError, TimeError
import unicodedata
class ValidatorBase: class ValidatorBase:
"""Even more minimalistic base class for validators. """Even more minimalistic base class for validators.
...@@ -268,6 +269,12 @@ class IntegerValidator(StringBaseValidator): ...@@ -268,6 +269,12 @@ class IntegerValidator(StringBaseValidator):
# we need to add this check again # we need to add this check again
if value == "" and not field.get_value('required'): if value == "" and not field.get_value('required'):
return value return value
try:
value = unicodedata.normalize('NFKD', value.decode('UTF8')).encode('ASCII', 'ignore')
except UnicodeDecodeError:
pass
try: try:
if value.find(' ')>0: if value.find(' ')>0:
value = value.replace(' ','') value = value.replace(' ','')
...@@ -295,6 +302,11 @@ class FloatValidator(StringBaseValidator): ...@@ -295,6 +302,11 @@ class FloatValidator(StringBaseValidator):
if value == "" and not field.get_value('required'): if value == "" and not field.get_value('required'):
return value return value
try:
value = unicodedata.normalize('NFKD', value.decode('UTF8')).encode('ASCII', 'ignore')
except UnicodeDecodeError:
pass
input_style = field.get_value('input_style') input_style = field.get_value('input_style')
decimal_separator = '' decimal_separator = ''
decimal_point = '.' decimal_point = '.'
......
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