Core: Remove native String#trim usage to save size

(cherry-picked from 279913c71b63da721fa2f118cdce150effbf773e)

Fixes #14794