views:

85

answers:

2

Hi, I have column named "summary" (tinytext, utf8_turkish_ci). I know it can store 255 byte also 255 chars. But if i use unicode chars like Ç, Ö, Ü storage capacitiy naturally decreasing. If my visitor enter 250 chars long unicode text then last chars are erasing. My summary column will be always 250 chars long. What can i do ? Thanks.

+3  A: 

You could turn it into a varchar instead. The length of a varchar is limited to the number of characters you specify. The length of a tinytext field is limited to 255 bytes.

mercator
An additional note: In MySQL 5, Innodb will only allow a key of 767 bytes, though fields that are not part of a key may be longer. Since the OP is using a utf8 character set and MySQL uses 3 bytes per character, a `varchar` field in a key will have a limit of 255.67 characters, which in practice means a maximum of 255 characters. As the OP only needs 250 chars, this should be sufficient.
Adam Franco
A: 

UTF-8 is variable length encoding. A char can be encoded into 1 to 4 bytes (theoretically limit is 6 but I haven't encountered it yet). If you are dealing with Turkish only, only 2 bytes is needed for each char. So you will need a column size of 500 bytes to support 250 chars so you should use something like varchar(500) or text.

ZZ Coder