added encoding debug logging