localeconv() - 数値規則の照会

標準

標準/拡張機能 C/C++ 依存項目

ISO C
XPG4
XPG4.2
C99
Single UNIX Specification、バージョン 3

両方  

形式

#include <locale.h>

struct lconv *localeconv(void);

機能説明

struct lconv を持つ構造体のコンポーネントに、現行ロケール に適切な値を設定します。構造体は、別の呼び出しにより localeconv() 呼び出しに上書きされたり、setlocale() を呼び出して LC_ALL、LC_MONETARY、または LC_NUMERIC を渡すことによって上書きされます。

lconv 構造体のエレメントのリストについては、表 1 を参照してください。

"" の値のストリングへのポインターは、値が C ロケールでは使用できない、または長さが 0 であることを示します。値が UCHAR_MAX の char 型は、値が現行ロケールで使用できない ことを示します。

戻り値

構造体へのポインターを戻します。

CELEBL06
⁄* CELEBL06                                      

   This example prints out the default decimal point for your locale and        
   then the decimal point for the Fr_CA locale.                                 

 *⁄                                                                             
#include <stdio.h>                                                              
#include <locale.h>                                                             
                                                                                
int main(void)                                                                  
{                                                                               
  char * string;                                                                
  struct lconv * mylocale;                                                      
  mylocale = localeconv();                                                      
  ⁄* Display default decimal point *⁄                                           
  printf( "Default decimal point is a %s¥n",
            mylocale->decimal_point );                                          
                                                                                
  if (NULL != (string = setlocale(LC_ALL, "Fr_CA.IBM-1047" )))                  
  {                                                                             
     mylocale = localeconv();                                                   
     ⁄* A comma is set to be the decimal point                                  
        when the locale is Fr_CA.IBM-1047 *⁄                                    
  printf( "French-speaking Canadian decimal point is a %s¥n",
            mylocale->decimal_point );                                          
   }                                                                            
   else {                                                                       
      printf("setlocale(LC_ALL, Fr_CA.IBM-1047) returned <NULL>¥n");
   }                                                                            
   return 0;                                                                    
}                                                                               
出力:
Default decimal-point is a .
French-speaking Canadian decimal-point is a ,

関連情報