encode text before parsing