|
|
|
date: Sun, 20 Jul 2008 21:32:11 -0600,
group: microsoft.public.dotnet.framework.sdk
back
RE: String.Format - offset of inserted text?
Hello Dave,
Do you mean the output of String.Format by "the created string"? Are the
string format with {0} {1} and the arguments still available when we need
to calculate the offset? If yes, we can do it by parsing the string format
character by character:
We look forward from the first char of the string format. In the meantime,
we have an integer to record the current offset. If we meet with '{', we
determine whether the value between this '{' and the next '}' is an
integer. If it returns true, we get the argument corresponds to the integer
from the argument collection, and update the current offset by adding the
length of the argument value. In this way, we will be able to retrieve the
offsets of all the arguments.
Please let me know whether this solution is helpful or not.
Regards,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
date: Mon, 21 Jul 2008 10:31:04 GMT
author: (Jialiang Ge [MSFT])
Re: String.Format - offset of inserted text?
Hi;
I was afraid that was the answer. The problem is that the string "hi
{0} there {1}" in English can be "there {1} hi {0}" in Chinese and we
need to offsets after the formatted string is created.
We'll implement as you suggested below - it would have been nice if
String.Format had a version that returned to offset and length of each
inserted string.
thanks - dave
On Mon, 21 Jul 2008 10:31:04 GMT, jialge@online.microsoft.com
("Jialiang Ge [MSFT]") wrote:
>Hello Dave,
>
>Do you mean the output of String.Format by "the created string"? Are the
>string format with {0} {1} and the arguments still available when we need
>to calculate the offset? If yes, we can do it by parsing the string format
>character by character:
>
>We look forward from the first char of the string format. In the meantime,
>we have an integer to record the current offset. If we meet with '{', we
>determine whether the value between this '{' and the next '}' is an
>integer. If it returns true, we get the argument corresponds to the integer
>from the argument collection, and update the current offset by adding the
>length of the argument value. In this way, we will be able to retrieve the
>offsets of all the arguments.
>
>Please let me know whether this solution is helpful or not.
>
>Regards,
>Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
>Microsoft Online Community Support
david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com
Cubicle Wars - http://www.windwardreports.com/film.htm
date: Mon, 21 Jul 2008 10:29:56 -0600
author: David Thielen am
|
|