Problem with username and non-ascii chars...
Community Forums/General Help/Problem with username and non-ascii chars...
| ||
The title says pretty much everything. I'm getting the username (to display initially on my game) with
username=getenv_("USERNAME")
(of course, on Mac I just use "USER") But at least on Windows, if the username have non-ascii chars, it only displays as a bunch of '????' when I draw it on screen. Is there anyway I can change that to a common ascii char string? Or at least check it against strange chars, and just use a default username instead? Last edited 2011 |
| ||
| Try the _wgetenv_s. Don't know if this will work. |
| ||
| Hmmm? I get 'identifier not found' using _wgetenv_s ? I see it's a Windows API call, but don't know exactly how it could help me :( Last edited 2011 |
| ||
| Yes, it's an API call: http://msdn.microsoft.com/en-us/library/aa246422(VS.60).aspx The name appears to be _wgetenv actually, and it handles wide-character (unicode) strings. This will allow you to have those strange characters in your usernames. BlitzMax offers support for externed WStrings with the "$w" suffix. Use it like so:
SuperStrict
Framework brl.basic
Import "-enable-stdcall-fixup"
Extern "win32"
Function _wgetenv$w( varname$w )
End Extern
Print _wgetenv("USERNAME")
|
| ||
| Actually, the problem has nothing to do with the call :( Both _wgetenv and getenv_ are returning the same string, which in the debug is shown correclty - but when I use "print" or "drawtext", it prints the string incorrectly. And here's the kick: it works fine on XP, but not on Seven-64 bits. Edit: nevermind - I updated my brl.mod folder, and now everything works :) Last edited 2011 |
| ||
Load any font other than the default.
SetImageFont(LoadImageFont(getenv_("windir") + "\fonts\arial.ttf", 24, SMOOTHFONT))
Taken from this thread.Last edited 2011 |