Subject: Re: a proposal for two new libc functions: shquote() and shquotev()
To: Jun-ichiro itojun Hagino <>
From: Chris G. Demetriou <>
List: tech-userlevel
Date: 03/03/2001 22:49:20
Jun-ichiro itojun Hagino <> 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:


will turning that into the string:


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 Demetriou - -
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.