Fix sub string function for thai character.