Skip to content

Commit

Permalink
Add pg_all_utf8() which returns all valid UTF-8 characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
MasaoFujii committed May 25, 2016
1 parent 26a6129 commit fdfa72b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,17 @@ than 1114111.
### text pg_utf8(code integer)
Alias of [pg_chr](https://github.com/MasaoFujii/pg_cheat_funcs#text-pg_chrcode-integer) function.

### SETOF record pg_all_utf8()
Return all valid UTF-8 characters.
This function returns a record, shown in the table below.

| Column Name | Data Type | Description |
|-------------|-----------|-------------------|
| code | text | code of character |
| utf8 | text | UTF-8 character |

This function can be executed only under UTF-8 database encoding.

### text pg_eucjp(code1 bit(8), code2 bit(8), code3 bit(8))
Return EUC_JP character with the given codes.
The following table shows the valid combination of the codes.
Expand Down
7 changes: 7 additions & 0 deletions pg_cheat_funcs--1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ RETURNS text
AS 'MODULE_PATHNAME', 'pg_chr'
LANGUAGE C STRICT IMMUTABLE;

CREATE FUNCTION pg_all_utf8(OUT code integer, OUT utf8 text)
RETURNS SETOF record AS
'SELECT * FROM
(SELECT code, pg_utf8(code) utf8 FROM generate_series(0, 1114111) code) tmp
WHERE utf8 IS NOT NULL'
LANGUAGE SQL IMMUTABLE;

CREATE FUNCTION pg_eucjp(bit(8), bit(8) DEFAULT 'x00', bit(8) DEFAULT 'x00')
RETURNS text
AS 'MODULE_PATHNAME'
Expand Down

0 comments on commit fdfa72b

Please sign in to comment.