Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Sun, 20 Jul 2008 21:32:11 -0600,    group: microsoft.public.dotnet.framework.sdk        back       


String.Format - offset of inserted text?   
Hi;

I need a way to know at what offset in the created string all the text
for each {0}, {1}, etc are placed. Is there some way to do this?

thanks - dave


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: Sun, 20 Jul 2008 21:32:11 -0600   author:   David Thielen am

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

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us