niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » Linux » development » apps
Is there C/C++ corresponding function in Linux for Java's java.util.Locale.getCountry?
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
Author Message
xiebopublic@gmail.com
*nix forums beginner


Joined: 27 Jul 2005
Posts: 9

PostPosted: Fri Jul 21, 2006 3:22 am    Post subject: Is there C/C++ corresponding function in Linux for Java's java.util.Locale.getCountry? Reply with quote

Hi all,
Is there C/C++ corresponding function in Linux for Java's
java.util.Locale.getCountry? Thanks!

Best Regards,
Xie, Bo
Back to top
Josef Moellers
*nix forums Guru


Joined: 28 Feb 2005
Posts: 426

PostPosted: Fri Jul 21, 2006 6:46 am    Post subject: Re: Is there C/C++ corresponding function in Linux for Java's java.util.Locale.getCountry? Reply with quote

xiebopublic@gmail.com wrote:
Quote:
Hi all,
Is there C/C++ corresponding function in Linux for Java's
java.util.Locale.getCountry? Thanks!

getenv("LANG")?

--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
Back to top
Josef Moellers
*nix forums Guru


Joined: 28 Feb 2005
Posts: 426

PostPosted: Fri Jul 21, 2006 6:48 am    Post subject: Re: Is there C/C++ corresponding function in Linux for Java's java.util.Locale.getCountry? Reply with quote

xiebopublic@gmail.com wrote:
Quote:
Hi all,
Is there C/C++ corresponding function in Linux for Java's
java.util.Locale.getCountry? Thanks!

Best Regards,
Xie, Bo


getenv("LANG")?

--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
Back to top
Binary
*nix forums addict


Joined: 25 Mar 2005
Posts: 83

PostPosted: Fri Jul 21, 2006 9:17 am    Post subject: Re: Is there C/C++ corresponding function in Linux for Java's java.util.Locale.getCountry? Reply with quote

man locale

xiebopublic@gmail.com wrote:
Quote:
Hi all,
Is there C/C++ corresponding function in Linux for Java's
java.util.Locale.getCountry? Thanks!

Best Regards,
Xie, Bo
Back to top
Roger Leigh
*nix forums Guru


Joined: 28 Feb 2005
Posts: 364

PostPosted: Fri Jul 21, 2006 9:46 am    Post subject: Re: Is there C/C++ corresponding function in Linux for Java's java.util.Locale.getCountry? Reply with quote

On 2006-07-21, Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote:
Quote:
xiebopublic@gmail.com wrote:
Hi all,
Is there C/C++ corresponding function in Linux for Java's
java.util.Locale.getCountry? Thanks!

Best Regards,
Xie, Bo

getenv("LANG")?

No. It might not be set, and there are quite a lot of other LC_*
environment variables to consider in addition.

#include <iostream>
#include <locale>

int main()
{
std::string localename = std::locale("").name();
std::string::size_type pos;
bool status = false;

// Strip off any charset.
if ((pos = localename.find_first_of('.')) != std::string::npos)
localename = localename.substr(0, pos);

std::cerr << localename << std::endl;

// Strip off language, retaining territory.
if ((pos = localename.find_first_of('_')) != std::string::npos &&
localename.size() > pos + 1)
localename = localename.substr(pos + 1);
else
localename = "";

std::cerr << localename << std::endl;
}
Also consider that in C++, you may have a separate locale imbued into
each output stream; you may wish to get the locale from the stream,
instead of using the default locale as above.


Regards,
Roger

--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please sign and encrypt your mail.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
The time now is Sun Nov 23, 2008 2:11 pm | All times are GMT
navigation Forum index » *nix » Linux » development » apps
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Help required for configuring the VPN Server in Linux SHERDIL security 0 Sun Nov 19, 2006 2:22 pm
No new posts Function Pointer Sikandar C 3 Fri Jul 21, 2006 1:23 pm
No new posts Arbitrary function with parameter darknails@gmail.com C++ 2 Fri Jul 21, 2006 9:58 am
No new posts question for JAVA developer who r using postgres sql as b... deepak pal PostgreSQL 1 Fri Jul 21, 2006 9:00 am
No new posts 2 USB webcams on Linux 2.6.15.4 produce a hang Suyog hardware 1 Fri Jul 21, 2006 7:27 am

Debt Consolidation | Loans | Busby SEO Test | Mortgages | Home Loan
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1763s ][ Queries: 16 (0.0947s) ][ GZIP on - Debug on ]