Closed Bug 12430 Opened 25 years ago Closed 25 years ago

[feature] need sprintf support for unichar strings

Categories

(Core :: Internationalization, defect, P3)

x86
Other
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: cathleennscp, Assigned: ftang)

References

Details

Blocks: 9589
No longer blocks: 9589
Blocks: 9589
Status: NEW → ASSIGNED
Target Milestone: M11
Dan: I am not quite sure what do you need here.
I assume you need to following
1.The output buffer is a nsString
2. The input format string is a nsString
3. It take variable length of nsString argument, and the argument can only be
nsString
4. The format string may include position argument , e.g. "%3$s %2$s %1$s" etc
5. It does not need other type of argument than nsString
I assume we don't want the arguments to be nsStrings since this functionality
will live in one module and be called from elsewhere. we're supposed to be
using wstring in interfaces.

But yes, this is basically what I want. A more flexible version would allow for
both cstring and wstring arguments (with appropriate format codes, of course),
but if people had to they could always promote everything to wstring first.
Mostly I'm pretty sure all the fragments and formats I've got are wstring. It'd
be nice if all the other usual sprintf formatting were still supported, but I
guess we could always do things in two or three steps.
 - sprintf fragment with number argument
 - convert to wstring
 - feed into wsprintf.

That's problematic if there are multiple replacements because then they can't
be truly reorderable unless we're careful to convert each argument separately.
add scott here since he also depend on this from the traction meeting.
I will start work on this early next week.

Where should we put this thing ? mozilla/xpcom/ds/nsCRT.cpp ???? Kipp, any
opinion ?
add scott here since he also depend on this from the traction meeting.
I will start work on this early next week.

Where should we put this thing ? mozilla/xpcom/ds/nsCRT.cpp ???? Kipp, any
opinion ?
have problem to add Scott Putterman to the CC
I think we basically need what's been mentioned in the bug already.  David,
anything else you want to add.  From talking to Frank it sounds like it will be
hard to do arguments besides strings such as ints.  If that's the case we could
always use smprintf to create those parts of the string that this new function
can't handle.
A couple of suggestions - PR_snprintf and cousins exist, are our code, and can
be freely cut & pasted into new situations (like this).

Before you do that, though, see if you can get wtc to bite on adding support to
nspr for it directly. Life becomes much simpler then. IMHO, its a reasonable
feature request for nspr - modern programs are i18n aware and have to deal with
this problem. That's why PRUnichar should be in nspr :-)

However, I don't know if nspr supports the positional argument notation yet. If
it doesn't, see if you can sign him up for that too.

By the way, if he balks at the work, maybe frank can do the work and wtc can
review it and check it in?

Adding wtc to the list of interested persons...feel free to remove yourself if
you don't like it.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
I have check in the code to mozilla/xpcom/ds/nsTextFormater.cpp
The position stuff is done by jliu two years ago inside NSPR.

I add %S to take PRUnichar* as argument.
Also, %s only mean UTF8 string, not anything else. The reason that we
need to spec out it AS UTF8 is because we need to convert from char* to
PRUnichar* inside the snprintf.

Code got check in and build in all three platform.

Mark it fix. Reopen this if you find any problem.
QA Contact: teruko → cathleen
Cathleen, can you verify? Thanks.
You need to log in before you can comment on or make changes to this bug.