I am running as root, but have the user's uid (e.g. 504
). How can I work out the user's locale (in my case en_GB
)? The following does not work:
setuid(user_uid);
fprintf(stderr,
CFStringGetCStringPtr(CFLocaleGetIdentifier(CFLocaleCopyCurrent()),
kCFStringEncodingMacRoman);
setuid(0);
This outputs en_US
for me.