开发者

Encoded string length greater than max specified for user

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 s开发者_Go百科ituation?


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.


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜