0

I'm using ASP.NET with sql-server. I have an area where the user can enter text of a maximum amount. I encode this text as a good measure but the encoded length can be greater than this maximum amount when I try to insert it into the database.

Special characters are encoded on 3 characters. I can't show the user that he has exceeded the max amount of characters because from his perspective he hasn't. I also can't set the database field to the worst case scenario (being 3 times my max amount).

What would you do in this situation?

4

2 回答 2

0

If your database is storing the text as unicode, then you don't need to encode it before being saved. You only need to encode it when you send it back to the client.

于 2011-04-04T15:46:10.730 回答
0

I think I'd make the field 3 times longer (but as a varchar to save space) or find a different encoding mechanism (although that is still likely to require more space).

Sorry I can't be of more help!

于 2011-04-04T15:46:19.030 回答