PC Review


Reply
Thread Tools Rate Thread

ascii length??

 
 
Algren
Guest
Posts: n/a
 
      23rd Feb 2004
hi all,

I am wondering how I can get the ascii lengh of a string in VB.NET?
Especially that the string consists of alpha numerics as well as chinese
(double-byte) characters. Say I have a string "AB123" with the first 2
characters being double-byte, using Len() on that string would return me 5.
How can I get a value of 7 instead?? is there any VB.NET function that'd
achieve that?

Thanks a lot and your help's greatly appreciated.


 
Reply With Quote
 
 
 
 
EricJ
Guest
Posts: n/a
 
      23rd Feb 2004
just a thought haven't tried this
did you try to convert the string to a char array and take the length of
that (if the double-byte chars count as 2 ascii chars that might work)

hope it helps

eric

"Algren" <(E-Mail Removed)_SPAM> wrote in message
news:e0J6zKe%(E-Mail Removed)...
> hi all,
>
> I am wondering how I can get the ascii lengh of a string in VB.NET?
> Especially that the string consists of alpha numerics as well as chinese
> (double-byte) characters. Say I have a string "AB123" with the first 2
> characters being double-byte, using Len() on that string would return me

5.
> How can I get a value of 7 instead?? is there any VB.NET function that'd
> achieve that?
>
> Thanks a lot and your help's greatly appreciated.
>
>



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      23rd Feb 2004
Hi Algren,

Ascii string (I will be before Armin), do you mean the amount of 7 bits
occurences in the string?

Normaly a string gives back the lenght of char in the used unicode. (I do
not think that is different with Chinese with other types).

I never heard of a mixed up string which has different types of unicode in
it.

But just my thoughts,

Cor


>
> I am wondering how I can get the ascii lengh of a string in VB.NET?
> Especially that the string consists of alpha numerics as well as chinese
> (double-byte) characters. Say I have a string "AB123" with the first 2
> characters being double-byte, using Len() on that string would return me

5.
> How can I get a value of 7 instead?? is there any VB.NET function that'd
> achieve that?
>



 
Reply With Quote
 
Algren
Guest
Posts: n/a
 
      23rd Feb 2004
hi Eric,

I tried that and it still gave the same result.

Thanks

"EricJ" <(E-Mail Removed)> 在郵件
news:4039b4fa$0$319$(E-Mail Removed) 中撰寫...
> just a thought haven't tried this
> did you try to convert the string to a char array and take the length of
> that (if the double-byte chars count as 2 ascii chars that might work)
>
> hope it helps
>
> eric
>
> "Algren" <(E-Mail Removed)_SPAM> wrote in message
> news:e0J6zKe%(E-Mail Removed)...
> > hi all,
> >
> > I am wondering how I can get the ascii lengh of a string in VB.NET?
> > Especially that the string consists of alpha numerics as well as chinese
> > (double-byte) characters. Say I have a string "AB123" with the first

2
> > characters being double-byte, using Len() on that string would return me

> 5.
> > How can I get a value of 7 instead?? is there any VB.NET function that'd
> > achieve that?
> >
> > Thanks a lot and your help's greatly appreciated.
> >
> >

>
>



 
Reply With Quote
 
Algren
Guest
Posts: n/a
 
      23rd Feb 2004
hi Cor,

First thanks for replying.

"Cor" <(E-Mail Removed)> 在郵件 news:OF0V3Ze%(E-Mail Removed) 中撰
寫...
> Hi Algren,
>
> Ascii string (I will be before Armin), do you mean the amount of 7 bits
> occurences in the string?
>

I think so. Just the effect of the first two characters being wider than
other alpha numerics

> Normaly a string gives back the lenght of char in the used unicode. (I do
> not think that is different with Chinese with other types).
>
> I never heard of a mixed up string which has different types of unicode in
> it.


Perhaps what I need is a way of distinguishing a double-byte word from
alpha-numerical characters in the same used unicode.
The problem is that with unicode I think every charater is treated as two
bytes.

>
> But just my thoughts,
>
> Cor
>
>
> >
> > I am wondering how I can get the ascii lengh of a string in VB.NET?
> > Especially that the string consists of alpha numerics as well as chinese
> > (double-byte) characters. Say I have a string "AB123" with the first

2
> > characters being double-byte, using Len() on that string would return me

> 5.
> > How can I get a value of 7 instead?? is there any VB.NET function that'd
> > achieve that?
> >

>
>



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      23rd Feb 2004
Hi Algren,
>
> Perhaps what I need is a way of distinguishing a double-byte word from
> alpha-numerical characters in the same used unicode.
> The problem is that with unicode I think every charater is treated as two
> bytes.
>

That is what I know from it.

Cor


 
Reply With Quote
 
Zack Sessions
Guest
Posts: n/a
 
      23rd Feb 2004
"Algren" <(E-Mail Removed)_SPAM> wrote in message news:<e0J6zKe#(E-Mail Removed)>...
> hi all,
>
> I am wondering how I can get the ascii lengh of a string in VB.NET?
> Especially that the string consists of alpha numerics as well as chinese
> (double-byte) characters. Say I have a string "AB123" with the first 2
> characters being double-byte, using Len() on that string would return me 5.
> How can I get a value of 7 instead?? is there any VB.NET function that'd
> achieve that?
>
> Thanks a lot and your help's greatly appreciated.


The Len() function is provided for backwards compatability with VB6.
The "proper" way to obtain a string variable's current length is with
the String Class's .Length property. For example:

Dim myString as String

myString = "some value"
messagebox.show ("current length is " & myString.Length)

Does this give the same results?
 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      23rd Feb 2004
Hi Zack,

>
> The Len() function is provided for backwards compatability with VB6.
> The "proper" way to obtain a string variable's current length is with
> the String Class's .Length property. For example:
>
> Dim myString as String
>
> myString = "some value"
> messagebox.show ("current length is " & myString.Length)


The string.length() function is provided for backwards compatabilitity with
C.

(I think that it else maybe had been count as all modern array's)

Len() is a full Net framework function (As is the string.length() function
also before you understand it wrong).

It are both "proper" ways to obtain a string variable's current length.

Just before people understand it wrong.

Cor




 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      23rd Feb 2004
* "Algren" <(E-Mail Removed)_SPAM> scripsit:
> I am wondering how I can get the ascii lengh of a string in VB.NET?
> Especially that the string consists of alpha numerics as well as chinese
> (double-byte) characters. Say I have a string "AB123" with the first 2
> characters being double-byte, using Len() on that string would return me 5.
> How can I get a value of 7 instead?? is there any VB.NET function that'd
> achieve that?


'System.Text.Encoding.ASCII.GetBytes', then get the length of the
returned array.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Algren
Guest
Posts: n/a
 
      24th Feb 2004
hi Zack,

Thanks for replying...

>
> The Len() function is provided for backwards compatability with VB6.
> The "proper" way to obtain a string variable's current length is with
> the String Class's .Length property. For example:
>
> Dim myString as String
>
> myString = "some value"
> messagebox.show ("current length is " & myString.Length)
>
> Does this give the same results?


Yeah it does, unfortunately.
I guess I am looking for a way to break the existing unicode encoding in
VB.NET or manually parse my string to filter ANSI and double-byte
characters. Any ideas?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create an ASCII Fixed Length File from Excel Laura Microsoft Excel Misc 3 24th Jan 2008 09:56 PM
HELP! How to do mixed length record export from Access ? (EDI Fixed Length Ascii or X.12) tmb Microsoft Access 4 23rd Mar 2005 08:11 AM
READ FIXED LENGTH ASCII FORMAT =?Utf-8?B?QW5u?= Microsoft Access External Data 9 9th Jan 2005 10:11 PM
importing delimited ascii file with zero-length strings VMI Microsoft Access 1 20th Dec 2004 11:41 PM
Reading Fixed Length ASCII/Text File Ken Hall Microsoft VB .NET 3 19th Nov 2003 06:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 AM.