[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UDUNITS #BUK-910616]: ut_get_name() returning NULL?



David,

ut_get_name(ut_get_unit_by_name(theUnitSystem, "pound") returns NULL because 
"theUnitSystem" is the SI system of units, which doesn't have a "pound".

I know it seems like you should recover the name. I had to take some shortcuts 
in order to keep the development time down and this was one of the sacrifices.

> Hi Steve,
> 
> I am having a problem with the ut_get_name() function not returning the
> name sometimes.
> If I do:
> 
> theUnitsSystem = ut_read_xml( NULL );
> unit1 = ut_get_unit_by_name( theUnitsSystem, "kilogram" );
> if( !unit1 ) {
> printf( "***** ut_get_unit_by_name for \"kilogram\" returned NULL\n" );
> } else {
> printf( "ut_get_unit_by_name( \"kilogram\" ) returned \"%s\"\n", ut_get_name( 
> unit1, UT_ASCII ) );
> }
> unit2 = ut_get_unit_by_name( theUnitsSystem, "pound" );
> if( !unit2 ) {
> printf( "***** ut_get_unit_by_name for \"pound\" returned NULL\n" );
> } else {
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\" (ASCII)\n", 
> ut_get_name( unit2, UT_ASCII ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\" (LATIN1)\n", 
> ut_get_name( unit2, UT_LATIN1 ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\" (UTF8)\n", 
> ut_get_name( unit2, UT_UTF8 ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\"\n", ut_get_symbol( 
> unit2, UT_ASCII ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\"\n", ut_get_symbol( 
> unit2, UT_LATIN1 ) );
> printf( "ut_get_unit_by_name( \"pound\" ) returned \"%s\"\n", ut_get_symbol( 
> unit2, UT_UTF8 ) );
> }
> 
> The output I get is:
> 
> ut_get_unit_by_name( "kilogram" ) returned "kilogram"
> ut_get_unit_by_name( "pound" ) returned "(null)" (ASCII)
> ut_get_unit_by_name( "pound" ) returned "(null)" (LATIN1)
> ut_get_unit_by_name( "pound" ) returned "(null)" (UTF8)
> ut_get_unit_by_name( "pound" ) returned "(null)"
> ut_get_unit_by_name( "pound" ) returned "(null)"
> ut_get_unit_by_name( "pound" ) returned "(null)"
> 
> If I can get the unit by name, why can I not get the unit's name for pounds?
> 
> Thanks,
> David


Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: BUK-910616
Department: Support UDUNITS
Priority: Normal
Status: Closed


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.