Re: [Vala] Locale-insensitive version of String.printf



It seems that it is for binary serialization
rather than human-readable serialization.

It depends on what you need serialization for and what you mean human-readable.

Purpose: saving to a file. Mostly numbers and a few keywords.

Human-readable: what int.parse and double.parse can accept.
   i.e., typical programming format.

double.parse won't accept numbers formatted using printf
within a locale that uses commas for decimal points.

The other alternatives I found are not entirely satisfactory:
  1. double.to_string : cannot control the format like printf
  2. double.format : looks like an evil alien in vala

Anyhow, just to save you some time, let me propose the attached chunk of code.
Let me also point out a possible memory-leaking problem:
http://mail.gnome.org/archives/vala-list/2011-December/msg00077.html

Thanks. Variant is a bit overkill for my purpose now.
But it may be useful later.


Nice day
Nor Jaidi Tuah





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