fix failure when opening scalar ref that contains wide character