I have (in an SQLite database) the following string:
Лампа в вытяжке на кухне меняется, начиная с вытаскивания белого штырька справа.
The string is correctly shown by PHP using print. I would like to obtain just the first 50 chars of this string, i.e.
Лампа в вытяжке на кухне меняется, начиная с вытас.
I have tried using both the substr and mb_substr, and get
Лампа в вытяжке на кухне ме�, i.e. only 28 chars.
After reading here and elsewhere about the problems of mbstring, I realise that this is actually a 50 byte string (22 Russian chars = 44 bytes plus 5 spaces plus 1 question symbol).
Is there any nice solution to this? All my strings are UTF-8, so I could of course program a substr-function myself, by checking the first bit of every byte etc. But this should surely have been done before, right?
UPDATE: I believe mb_substr does not work properly because mb_detect_encoding() does not work properly.