This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
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