Fix clipboard device code so it works identically under non-wide-char platforms

This contribution was originally written by Richard Smolak.