[feature] need sprintf support for unichar strings

RESOLVED FIXED in M11

Status

()

P3
normal
RESOLVED FIXED
19 years ago
19 years ago

People

(Reporter: cathleennscp, Assigned: ftang)

Tracking

Trunk
x86
Other
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Updated

19 years ago
Blocks: 9589
(Reporter)

Updated

19 years ago
No longer blocks: 9589
(Reporter)

Updated

19 years ago
Blocks: 9589
(Assignee)

Updated

19 years ago
Status: NEW → ASSIGNED
(Assignee)

Updated

19 years ago
Target Milestone: M11
(Assignee)

Description

19 years ago
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.
(Assignee)

Comment 2

19 years ago
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 ?
(Assignee)

Comment 3

19 years ago
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 ?
(Assignee)

Comment 4

19 years ago
have problem to add Scott Putterman to the CC

Comment 5

19 years ago
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.

Comment 6

19 years ago
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.
(Assignee)

Updated

19 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → FIXED
(Assignee)

Comment 7

19 years ago
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.

Updated

19 years ago
QA Contact: teruko → cathleen

Comment 8

19 years ago
Cathleen, can you verify? Thanks.
You need to log in before you can comment on or make changes to this bug.