Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ nlfmtnum(3X) — HP-UX ANSI C A.09.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

nlconvnum(3X)

portnls(5)

nlfmtnum(3X)

NAME

nlfmtnum() − convert an ASCII number to an MPE language-specific formatted number

SYNOPSIS

#include <portnls.h>

void nlfmtnum(

short int langid,
const char *instr,
short int leninstr,
char *outstr,
short int *plenoutstr,
unsigned short int err[2],
const char *numspec,
short int fmtmask,
short int decimals

);

DESCRIPTION

nlfmtnum() converts a string containing an ASCII number to a language-specific formatted number using the currency name/symbol, decimal separator, and thousands separators defined for the language.  The string may contain the n-computer decimal separator (.), thousands separator (,), and a dollar sign ($). 

This routine operates in two modes: substitution mode and formatting mode.  The substitution mode (if fmtmask is zero) substitutes the native equivalent for .  and , and, for arabic, the alternate set of digits for ASCII digits.  The input is not validated as a number, and can contain several individual numbers.  No justification takes place, and the output is left-truncated if outstr is shorter than instr (for example, 1,234.56 becomes 234,56). 

If fmtmask is not zero, the formatting mode formats the input according to fmtmask in addition to performing the substitution.  In this mode the input is validated as a number and only ASCII digits and -, +, $, ., and , are allowed.  Only one sign and one $ is allowed and they must be the first character(s) in instr. Even if insertion (of thousands separators, etc.) is specified in fmtmask, thousands separators and a decimal separator are still valid characters in the input. In this case they are substituted. If no justification is specified, the output is right-justified with the same number of trailing spaces as the input. Note that for languages written right-to-left, trailing spaces in the input are preserved as leading spaces in the output. If the output is truncated, it is left-truncated (for example, 1,234.56 becomes .234,56). 

Arguments to nlfmtnum() are used as follows:

langid A language ID number specifying which language’s formatting specifications to use for the formatting. 

instr A byte array containing the n-computer formatted ASCII number to be converted, for example, 123,456.78.  Leading and trailing spaces are allowed. 

leninstr Length, in bytes, of instr.

outstr A byte buffer where the language-specific formatted number is returned.  The decimal separator, thousands separator, and currency symbol/name are replaced according to the language definition, if present or inserted, or if specified by fmtmask. outstr can reference the same address as instr.

plenoutstr Length, in bytes, of outstr. After a successful call, if specified by fmtmask (the two bits starting with bit 12 (from highest to lowest) are equal to 3), plenoutstr returns the actual length, in bytes, of the formatted number. 

err The first element of this array contains the error number.  The second element is always zero.  If the call is successful, both elements contain zero. 

Error # Meaning

2 Specified language is not configured,

3 Invalid length specified (leninstr or ∗plenoutstr).

4 Invalid number specified (instr).

5 Invalid decimal point in number specified (instr).

6 Invalid thousand separators in number specified (instr).

7 Truncation has occurred (outstr is left partially formatted). 

8 Invalid numspec parameter. 

9 Invalid fmtmask parameter. 

10 Invalid decimals parameter. 

numspec A byte array, as returned from nlnumspec(), containing formatting specifications for the specified language (currency symbol/name, decimal separator, etc.).  If this parameter is not null, langid is ignored, and performance is improved.  (See nlnumspec(3X)).

fmtmask A short integer value specifying any formatting to be done on the input.  The default value is zero, which means a simple substitution. 

Value Description

NULL Do not insert thousands separators. 
Do not insert decimal separator.
No justification of the output.

M_INSTHOU Insert thousands separators. 

M_INSDEC Insert decimal separator. 

M_CURRENCY Insert currency name/symbol. 

M_LEFTJUST The output is left-justified. 

M_RIGHTJUST Right-justify the output. 

M_RETLENGTH Left-justify the output and return the actual length of the formatted number in plenoutstr

decimals An integer specifying where to insert the decimal separator.  The value is ignored if fmtmask and M_INSDEC are zero, or a decimal separator is present in the number. 

WARNINGS

This routine is provided for compatibility with MPE, a proprietary HP operating system.  See portnls(5) for more information on the use of this routine. Use the Native Language Support routines for C programmers described by hpnls(5) for HP-UX NLS support. 

AUTHOR

nlfmtnum() was developed by HP. 

SEE ALSO

nlconvnum(3X), portnls(5). 

EXTERNAL INFLUENCES

International Code Set Support

Single- and multi-byte character code sets are supported. 

Hewlett-Packard Company  —  HP-UX Release 9.0: August 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026