Hmm.. I tried commenting out the code you added to force encode NutrDef and FoodDes entries and didn't run into any encoding errors.  Can you tell me what version of Ruby you're running?  Also, what operating system are you using?  It would be much better imho to avoid having to replace non-conforming characters.