Fix compile errors in upcase/downcase code

Review 1076 by @mlucy
Closes #1744