# snprintf + unicode

- Thread: https://externals.io/message/18051
- Original archive: https://news-web.php.net/php.internals/18051
- Started by Derick Rethans on 2005-08-14T13:34:55+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #18051 — Derick Rethans — 2005-08-14T13:34:55+00:00

URL: https://externals.io/message/18051#18051

Hei,

currently I've the following [pseudo] code:

	c = "";
	a = snprintf(buffer, 32, "%0d", day);
	b = snprintf(buffer, 32, "%s", daynames[dayofweek]);

	smartstr_appends(&c, a);
	smartstr_appends(&c, b);

	return c.c;

This snippet of code returns a legacy string. Now, as ICU provides the 
daynames as UTF16 encoded strings, I'm a bit lost as how to solve this. 
Of course I need to return a UNICODE string now, but which snprintf() 
like function should I use, so that %0d and friends are printed into the 
string as UTF16 string which I then can concat together, and return from 
the function?

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #18083 — Andrei Zmievski — 2005-08-15T03:15:16+00:00

URL: https://externals.io/message/18051#18083 · In reply to: #18051

http://icu.sourceforge.net/apiref/icu4c/ustdio_8h.html#a36

-Andrei




> Hei,
>
> currently I've the following [pseudo] code:
>
>     c = "";
>     a = snprintf(buffer, 32, "%0d", day);
>     b = snprintf(buffer, 32, "%s", daynames[dayofweek]);
>
>     smartstr_appends(&c, a);
>     smartstr_appends(&c, b);
>
>     return c.c;
>
> This snippet of code returns a legacy string. Now, as ICU provides the
> daynames as UTF16 encoded strings, I'm a bit lost as how to solve  
> this.
> Of course I need to return a UNICODE string now, but which snprintf()
> like function should I use, so that %0d and friends are printed  
> into the
> string as UTF16 string which I then can concat together, and return  
> from
> the function?
>
> Derick
>
> -- 
> Derick Rethans
> http://derickrethans.nl | http://ez.no | http://xdebug.org
