Port windows unicode fix from @da2ce7 to 4.x branch