Hi all,

I have a text file saved as utf8 without BOM. I loaded it into MysQL database.
An iframe is loaded with this data from MySQL. I need the caret position in the iframe in order to perform operations in the database. Everytime there's a new line the positions don't match.

For example: caret position 52 in iframe is the first character in a newline, and this letter in MySQL text column corresponds to substr(text,55,1), and the text is exactly the same..

Make sure that all parts work in the same character set - database, tables, fields, connection, html encoding, javascript encoding. The position differences most likely are due to one side counting the utf8 2-byte codes as one character, while the other side counts them as two characters.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.