Size of Rich Text Field in bytes

M

MattO

I have a form in which a user can add either Japanese or Engligh text into a
rich text field. I need to be able to limit the size of the entry to 255
bytes of text. (The unformatted portion). I've successfully stripped all
the tagging off of that node in the DOM, but I'm having trouble determining
the number of bytes in the string inside JScript.

I've tried: UFF8Encoding.GetByteCount(), but InfoPath doesn't recognize the
object. Any suggestions on the proper way to import this, or if it's even
possible?

Thanks

Matt
 
B

Brian Teutsch [MSFT]

I belive it can work like this...

..selectSingleNode(RichTextXPath);
..text - gives you the unformatted string of all children
..length - just what it says.
 
M

MattO

Thans Brian,

I agree that that should work, but I believe String.length will return the
number of characters. I need to account for both Japanese and English
strings.

Consider
String english;
String japanese;

if( english.length() == japanese.length() )

It is highly unlikely that: sizeInBytesOf( english) == sizeInBytesOf(
japanese )
Since almost all japanese characters require more than a byte of storage.

I need to limit the size of the field in bytes, not characters.

Thanks for your quick reply.

Matt
 
B

Brian Teutsch [MSFT]

Yeah, you got me there.

I don't see any examples of testing the byte size of a JScript char, so
hopefully someone else has an example.

Why does the byte size matter if you're going to have all the other HTML
formatting around it? Byte size is going to be an issue for all types of
fields, as well, so no way it's a simple database limitation for this field.
 
M

MattO

Oh well. Thanks

We store the whole form's xml blob on disk and save the unformatted version
of the headline in a varchar field in sybase for other uses. The headline
field in the DB is the issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top