textRange FindText

70 views
Skip to first unread message

Enes Karaca

unread,
Aug 10, 2013, 6:17:21 PM8/10/13
to ra...@googlegroups.com
Hello, I am having problems with findText.
Using relatively recent build of chromium.

the chars[] in findTextFromPosition is not the same length as the text. Therefore sometimes start startPos and/or endPos is outside of the chars[] range
I am assuming iterator(created with createCharacterIterator) is skipping some chars probably around pos.nextVisible(); (searching forward) but could not get any deeper than that.

p.s this does not always happen, only in some files, i am trying to find which chars are causing problems.


Message has been deleted

Quad

unread,
Aug 10, 2013, 7:07:34 PM8/10/13
to ra...@googlegroups.com
here is a test page:
(open console and enter searchManager.find("text") )
turns out the problem is Turkish capital letter İ (not I, it's with a dot on top)

problem with the letter is that in most languages
lowercase => uppercase
i => I

but in Turkish
i => İ(with doth)
ı(i without dot) => I(English capital i)

i assumed lowercase ı will also cause the same problem but it did not.
Any pointers how can i solve this? problem is probably somewhere around that letter, and i am guessing it's sort of a wider character than the normal characters, and converting it to lowercase in js probably produces strange stuff.

Quad

unread,
Aug 10, 2013, 7:13:32 PM8/10/13
to ra...@googlegroups.com
by the way it works in Firefox, not working in latest version of google chrome

Quad

unread,
Aug 10, 2013, 7:50:11 PM8/10/13
to ra...@googlegroups.com
It appears chrome treats İ differently than firefox, 

var str = "İİii".toLowerCase();
//str is iiii in all browsers at this point, but somehow chrome/chromium knows the first 2 are coming from İ
str.toUpperCase();

results in İİII in chromium.
but it results in IIII in other browsers.



solved by adding a line after line 1429 in textrange.js (handleMatch function inside the findTextFromPosition function )

before:
if (!isRegex && !findOptions.caseSensitive) {
  currentChar = currentChar.toLowerCase();
}
after:
if (!isRegex && !findOptions.caseSensitive) {
  if(currentChar == "İ")currentChar = "I"; 
  currentChar = currentChar.toLowerCase();
}




On Sunday, August 11, 2013 1:17:21 AM UTC+3, Quad wrote:
Reply all
Reply to author
Forward
0 new messages