On Mon, 4 Mar 2002 18:33:24 -0500 Glenn Maynard <[EMAIL PROTECTED]> wrote:
> On Mon, Mar 04, 2002 at 03:37:55PM -0500, Michael B Allen wrote: > > int enc_mbscpy(const char *src, char **dst, const char *tocode); > > int enc_mbsncpy(const char *src, size_t sn, char **dst, size_t dn, > > int wn, const char *tocode); > > > > char *dec_mbscpy_new(char **src, const char *fromcode); > > char *dec_mbsncpy_new(char **src, size_t sn, size_t dn, > > int wn, const char *fromcode); > > size_t dec_mbscpy(char **src, char *dst, const char *fromcode); > > size_t dec_mbsncpy(char **src, size_t sn, char *dst, size_t dn, > > int wn, const char *fromcode); > > > > for encodeing and decoding strings. The two main differences here are > > that we're converting to/from "many to one" where the "one" is the locale > > dependent multi-byte string encoding (e.g. UTF-8) and that in addition > > to contraining the operation by sn and dn bytes you can also contrain > > the operation by the number of characters wn. Mbsncpy_new is like a > > mbsndup and if dst is NULL for the dec_ functions it still works but > > Why not call it dec_mbs[n]dup? (I'd lean toward putting _dec/_enc at the > end, too, but that's just my habits.) Out of habit I use _new for anything that allocates memory but I suppose mbs[n]dup would be more consistent with common practice. Also these multi-byte string functions are part of a module called "encdec" the rest of which looks like: size_t enc_uint16be(uint16_t s, char *dst); size_t enc_uint32be(uint32_t i, char *dst); size_t enc_uint16le(uint16_t s, char *dst); size_t enc_uint32le(uint32_t i, char *dst); uint16_t dec_uint16be(const char *src); uint32_t dec_uint32be(const char *src); uint16_t dec_uint16le(const char *src); uint32_t dec_uint32le(const char *src); size_t enc_time(const time_t *timep, char *dst, int enc); time_t dec_time(const char *src, int enc); and along these lines I'd like to have enc_floatxx and dec_doublexx etc but I'm not very confident about decoding and encoding IEEE 754 without knowing for sure I'm not loosing precision. Anyway everything has enc_ or dec_. If it doesn't matter I'd rather be consistent. Mike -- May The Source be with you. -- Linux-UTF8: i18n of Linux on all levels Archive: http://mail.nl.linux.org/linux-utf8/
