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

This contribution was originally written by Richard Smolak.
Merge branch 'clipboard' of https://github.com/ladislav/r3 into community