PostgreSQL Source Code: src/backend/utils/adt/ascii.c File Reference (original) (raw)

#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include "[mb/pg_wchar.h](pg%5F%5Fwchar%5F8h%5Fsource.html)"
#include "[utils/ascii.h](ascii%5F8h%5Fsource.html)"
#include "utils/fmgrprotos.h"
#include "[varatt.h](varatt%5F8h%5Fsource.html)"

Go to the source code of this file.

Functions
static void pg_to_ascii (unsigned char *src, unsigned char *src_end, unsigned char *dest, int enc)
static text * encode_to_ascii (text *data, int enc)
Datum to_ascii_encname (PG_FUNCTION_ARGS)
Datum to_ascii_enc (PG_FUNCTION_ARGS)
Datum to_ascii_default (PG_FUNCTION_ARGS)
void ascii_safe_strlcpy (char *dest, const char *src, size_t destsiz)

RANGE_128

RANGE_160

ascii_safe_strlcpy()

void ascii_safe_strlcpy ( char * dest,
const char * src,
size_t destsiz
)

encode_to_ascii()

static text * encode_to_ascii ( text * data, int enc ) static

Definition at line 104 of file ascii.c.

105{

108 (unsigned char *) VARDATA(data),

109 enc);

110

112}

static void pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *dest, int enc)

References data, enc, pg_to_ascii(), VARDATA, and VARSIZE.

Referenced by to_ascii_default(), to_ascii_enc(), and to_ascii_encname().

pg_to_ascii()

static void pg_to_ascii ( unsigned char * src, unsigned char * src_end, unsigned char * dest, int enc ) static

Definition at line 29 of file ascii.c.

30{

31 unsigned char *x;

32 const unsigned char *ascii;

34

35

36

37

38#define RANGE_128 128

39#define RANGE_160 160

40

42 {

43

44

45

46 ascii = (const unsigned char *) " cL Y \"Ca -R 'u ., ?AAAAAAACEEEEIIII NOOOOOxOUUUUYTBaaaaaaaceeeeiiii nooooo/ouuuuyty";

48 }

50 {

51

52

53

54 ascii = (const unsigned char *) " A L LS \"SSTZ-ZZ a,l'ls ,sstz\"zzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTBraaaalccceeeeiiddnnoooo/ruuuuyt.";

56 }

58 {

59

60

61

62 ascii = (const unsigned char *) " cL YS sCa -R Zu .z EeY?AAAAAAACEEEEIIII NOOOOOxOUUUUYTBaaaaaaaceeeeiiii nooooo/ouuuuyty";

64 }

66 {

67

68

69

70 ascii = (const unsigned char *) " ' \" %S<STZZ `'\"\".-- s>stzz L A \"CS -RZ ,l'u .,as L\"lzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTBraaaalccceeeeiiddnnoooo/ruuuuyt ";

72 }

73 else

74 {

76 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),

77 errmsg("encoding conversion from %s to ASCII not supported",

79 return;

80 }

81

82

83

84

85 for (x = src; x < src_end; x++)

86 {

87 if (*x < 128)

90 *dest++ = ' ';

91 else

93 }

94}

int errcode(int sqlerrcode)

int errmsg(const char *fmt,...)

#define ereport(elevel,...)

Datum ascii(PG_FUNCTION_ARGS)

#define pg_encoding_to_char

static struct cvec * range(struct vars *v, chr a, chr b, int cases)

References ascii(), generate_unaccent_rules::dest, enc, ereport, errcode(), errmsg(), ERROR, pg_encoding_to_char, PG_LATIN1, PG_LATIN2, PG_LATIN9, PG_WIN1250, range(), RANGE_128, RANGE_160, and x.

Referenced by encode_to_ascii().

to_ascii_default()

to_ascii_enc()

Definition at line 138 of file ascii.c.

139{

142

145 (errcode(ERRCODE_UNDEFINED_OBJECT),

146 errmsg("%d is not a valid encoding code", enc)));

147

149}

#define PG_GETARG_INT32(n)

#define PG_VALID_ENCODING(_enc)

References data, enc, encode_to_ascii(), ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT32, PG_GETARG_TEXT_P_COPY, PG_RETURN_TEXT_P, and PG_VALID_ENCODING.

to_ascii_encname()

Definition at line 119 of file ascii.c.

120{

124

125 if (enc < 0)

127 (errcode(ERRCODE_UNDEFINED_OBJECT),

128 errmsg("%s is not a valid encoding name", encname)));

129

131}

#define PG_GETARG_NAME(n)

#define pg_char_to_encoding

References data, enc, encode_to_ascii(), ereport, errcode(), errmsg(), ERROR, NameStr, pg_char_to_encoding, PG_GETARG_NAME, PG_GETARG_TEXT_P_COPY, and PG_RETURN_TEXT_P.