2.8.6. _get_lc_monetary()

_get_lc_monetary() 必须返回一个指向 __lc_monetary_blk 结构的指针。 可以使用Example 2.13 中的宏来创建该结构。

Example 2.13. LC_MONETARY_DEF


__LC_MONETARY_DEF(lcmonetary_c, "C",	

                  "","","","","","","",	

                  255,255,255,255,255,255,255,255)	

__LC_MONETARY_DEF(lcmonetary_iso8859_1, "ISO8859-1",	

                  "STG ", "\243", ".", ",", "\3", "", "-",	

                  2, 2, 1, 0, 1, 0, 1, 2)	

__LC_INDEX_END(lcmonetary_dummy)



void const *_get_lc_monetary(void const *nullpara, char const *name) {	

    return _findlocale(&lcmonetary_c_index, name);	

}



void test_lc_monetary(void) {	

    struct lconv lc;	

    /*Test changing currency string as we change locales.*/	

    EQS(setlocale(LC_MONETARY, NULL), "C");         /* verify starting point */	

    _get_lconv(&lc); EQS(lc.currency_symbol, "");	

    EQI(!setlocale(LC_MONETARY, "ISO8859-1"), 0);

    EQS(setlocale(LC_MONETARY, NULL), "ISO8859-1");	

    _get_lconv(&lc); EQS(lc.currency_symbol, "\243");	

    EQI(!setlocale(LC_MONETARY, "C"), 0);

    EQS(setlocale(LC_MONETARY, NULL), "C");

    _get_lconv(&lc);	 EQS(lc.currency_symbol, "");  	 

}

Copyright © 2007 ARM Limited. All rights reserved. ARM DUI 0349AC
Non-Confidential