Harlequin RIP SDK
strutils.c File Reference

String-related utility functions. More...

#include "skinkit.h"
#include "hqnstrutils.h"
#include "hqmemcpy.h"
#include "mem.h"
#include "swcopyf.h"
#include <locale.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

Functions

const char * doubleToStr (char *pStr, int32 nSize, double fVal)
 Convert a double to string using the C locale. More...
 
double strToDouble (char *pStr, char **ppEndStr)
 Implementation of strtod() using the C locale. More...
 
uint8utl_strdup (uint8 *str)
 Simple version of strdup() since some platforms don't have it. More...
 

Detailed Description

String-related utility functions.

Function Documentation

◆ doubleToStr()

const char* doubleToStr ( char *  pStr,
int32  nSize,
double  fVal 
)

Convert a double to string using the C locale.

Parameters
[in]pStrThe buffer to contain the string
[in]nSizeThe size of the preallocated pStr buffer
[in]fValThe value to convert
Returns
a pointer to pStr
Note
The buffer pointed to by pStr should be big enough to store the string result otherwise "0" is returned. This function is needed to create locale independent printed floats for PostScript.

◆ strToDouble()

double strToDouble ( char *  pStr,
char **  ppEndStr 
)

Implementation of strtod() using the C locale.

Parameters
[in]pStrNull-terminated string to convert
[out]ppEndStrPointer to character that stops scan
Returns
the value of the floating-point number, except when the representation would cause an overflow, in which case it returns +/- HUGE_VAL.
Note
Equivalent to strtod_l(pStr, ppEndStr, NULL) which is available as part of the Standard C library but not available on all platforms.

◆ utl_strdup()

uint8* utl_strdup ( uint8 str)

Simple version of strdup() since some platforms don't have it.

Parameters
[in]strZero-terminated string to duplicate.
Returns
A new copy of input string str, or NULL if memory could not be allocated. If this function succeeds, it is the caller's responsibility to free the returned pointer using MemFree().