Skip to content

ntext

Japanese normalized-comparison text type for UTF-8 strings

ntext · Japanese normalized-comparison text type for UTF-8 strings

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100228ntextntext1.0TYPEUnknownC

Usage

Sources:

ntext defines a UTF-8 Japanese normalized-comparison text type. It normalizes hiragana, katakana, and half-width katakana to katakana; folds full-width and half-width Latin letters to lower-case half-width form; normalizes symbol width; and applies additional Japanese-specific substitutions before comparison.

CREATE EXTENSION ntext;

SELECT 'かな'::ntext = 'カナ'::ntext AS same_after_normalization;
SELECT pg_ntext_normalize('ABC'::ntext);
SELECT pg_similar_rate('東京都'::ntext, '東京'::ntext);

The extension provides comparison operators, a default B-tree operator class, pg_ntext_normalize(ntext), pg_similar_rate(ntext,ntext), and approximate-match operator /=. Index and equality semantics therefore follow the normalized representation rather than bytewise source text.

Some rules are deliberately lossy: the upstream document maps the ヴァ row to the バ row, maps historic kana such as ゐ/ヰ and ゑ/ヱ, rewrites を/ヲ, and removes a trailing prolonged-sound mark. Validate those choices against application search policy and retain the original text separately. The reviewed version is 1.0; upstream publishes neither a license statement nor a PostgreSQL compatibility matrix.

Table reader