Hi everyone,
I need some suggestion.
Actually i created a text box and wrote a java script to limit its character hold to 500 char. I made my related db column size to 508bytes(Oracle).
The functionality was working fine when i suddenly found a bug.
Say for example if i put 498char as normal char and last 2 as special character("", ~`) my db throws exception as the size is more than 508bytes. The reason behind is the size of special character being not same as normal character.
I thought of two ideas not sure how to proceed!.
Idea1: In my javascript where i check the number of character i will change it to check the total size of all character in bytes and keep it less than or equal to 500.
Problem: Is it really possible to get the byte size of character input in java script?
Idea2: In my java script i will modify the max size based on number of number of special character.
So something like this
MAX_SIZE = 500 - SPECIAL_CHARACTER * SPECIAL CHAR SIZE -1 or something similar.
Problem: Special character dont have fixed size i belive.. So how will i come to know whats the size of which character.
Any other approach are always invited..
Thanks for reading the post!