Subject: Re: a proposal for two new libc functions: shquote() and shquotev()
To: Jun-ichiro itojun Hagino <itojun@iijlab.net>
From: Chris G. Demetriou <cgd@netbsd.org>
List: tech-userlevel
Date: 03/03/2001 22:49:20
Jun-ichiro itojun Hagino <itojun@iijlab.net> writes:
> 	i vote for (3).  if you use mbrtowc() in shquote(), like printf() is
> 	using it,
> 	- if you are using C locale it works just like now
> 	- if you use some other locale setting, it wlil be supported
> 		but for /bin/sh, it won't be the case until we have setlocale()
> 		call in /bin/sh)

That actually looks pretty easy, but I'm unfamiliar with multibyte
chars so i've got a few more questions.

Will single-byte ASCII chars in a string containing (propertly-formed)
multi-byte chars actually be treated as single-byte ASCII chars?

i.e., say you have the string:

	<wch1><wch2><wch3>

will turning that into the string:

	'<wch1><wch2><wch3>'

actually have the intended effect, i.e. it'll be interpreted as 5
characters, the original three surrounded by single-quotes?

Is the mbstate_t handling in vfprintf() the portable way of doing that
initialization, etc?

Is including stdlib.h and checking for the definition of MB_CUR_MAX
the right way to tell whether or not you have multibyte support?


chris
-- 
Chris Demetriou - cgd@netbsd.org - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.