Locales, utf8, and spinbuttons



Folks,
	So, I was thinking about validating numeric entry, and I wanted
to see how to use localeconv().  Grepping brought me to gtkspinbutton.c,
gtk_spin_button_insert_text().  This brings up a couple questions and
problems.

Obvious problems:

o The spinbutton's validation loops on new_text_length.  If I understand
  the "insert_text" signal correctly, new_text_length is a byte count,
  not a character count, so this is not utf8 safe.
o The spinbutton checks the numeric value with ascii checks.  This is ok
  in utf8 against ascii numeral characters, but does not handle
  non-arabic numbers (IMO, it should be using g_unichar_is_digit() and
  g_unichar_digit_value()).

Questions:

o I want to do this properly.  Validating numeric input seems pretty
  straightforward, looping on g_utf8_next_char() and testing with
  is_digit() + digit_value().  But to validate the entry of
  positive/negative signs and decimal points requires the use of
  localeconv().  I can't find any docs explaining the format of
  lc->decimal_point, lc->negative_sign, and friends.  Are they in utf8,
  a locale specific encoding, or what?

Thanks
Joel

-- 

Life's Little Instruction Book #456

	"Send your loved one flowers.  Think of a reason later."

			http://www.jlbec.org/
			jlbec evilplan org




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]