英語版
このページの英語版を見る
std.ascii
ASCII文字を操作する関数。
std.asciiに含まれる関数はすべてUnicode文字を受け付けるが、Unicode文字でない場合は事実上無視される。
std.asciiに含まれるすべての関数はUnicode文字を受け付けるが、ASCII文字でない場合は事実上無視される。すべてのisX "関数"は、非ASCII文字に対して以下を返す。
false を返し、toX 関数は何もしない。
を返す。
Unicode文字を操作する関数については、以下を参照のこと。
std.uni.
License:
Authors:
出典 std/ascii.d
- immutable string
fullHexDigits
; - 0 .. 9A ..Fa ... f
- immutable string
hexDigits
; - 0 .. 9A ..F
- immutable string
lowerHexDigits
; - 0 ... 9A ... F
- immutable string
digits
; - 0 .. 9
- immutable string
octalDigits
; - 0 .. 7
- immutable string
letters
; - A ..za ... z
- immutable string
uppercase
; - A ..Z
- immutable string
lowercase
; - a ... z
- immutable string
whitespace
; - ASCII空白文字
- enum
LetterCase
: bool; - 文字の大文字小文字を指定する。Examples:
import std.conv : to; writeln(42.to!string(16, LetterCase.upper)); // "2A" writeln(42.to!string(16, LetterCase.lower)); // "2a"
Examples:import std.digest.hmac : hmac; import std.digest : toHexString; import std.digest.sha : SHA1; import std.string : representation; const sha1HMAC = "A very long phrase".representation .hmac!SHA1("secret".representation) .toHexString!(LetterCase.lower); writeln(sha1HMAC); // "49f2073c7bf58577e8c9ae59fe8cfd37c9ab94e5"
upper
- 大文字
lower
- 小文字
- enum
ControlChar
: char; - ASCIIテーブルのすべての制御文字(ソース)。Examples:
import std.algorithm.comparison, std.algorithm.searching, std.range, std.traits; // すべてのASCII文字はcharに収まるので、これらの文字もcharに収まる static assert(ControlChar.ack.sizeof == 1); // DELを除くすべての制御文字は、0から始まる行にある static assert(EnumMembers!ControlChar.only.until(ControlChar.del).equal(iota(32))); static assert(ControlChar.nul == '\0'); static assert(ControlChar.bel == '\a'); static assert(ControlChar.bs == '\b'); static assert(ControlChar.ff == '\f'); static assert(ControlChar.lf == '\n'); static assert(ControlChar.cr == '\r'); static assert(ControlChar.tab == '\t'); static assert(ControlChar.vt == '\v');
Examples:import std.conv; // 制御文字表はヘクスコードの代わりに使用できる。 with (ControlChar) assert(text("Phobos", us, "Deimos", us, "Tango", rs) == "Phobos\x1FDeimos\x1FTango\x1E");
nul
- なし
soh
- 見出しの開始
stx
- 本文の開始
etx
- 本文の終わり
eot
- 送信終了
enq
- 問い合わせ
ack
- 承認
bel
- ベル
bs
- バックスペース
tab
- 水平タブ
lf
- NL改行、改行
vt
- 垂直タブ
ff
- NPフォームフィード、改ページ
cr
- キャリッジリターン
so
- シフトアウト
si
- シフトイン
dle
- データリンクエスケープ
dc1
- デバイスコントロール1
dc2
- デバイス制御2
dc3
- 機器制御3
dc4
- デバイス制御 4
nak
- ネガティブ・アクノレッジ
syn
- 同期アイドル
etb
- 送信ブロックの終了
can
- キャンセル
em
- 媒体終了
sub
- 代替
esc
- エスケープ
fs
- ファイルセパレーター
gs
- グループセパレーター
rs
- レコードセパレータ
us
- 単位セパレータ
del
- 削除
- immutable string
newline
; - このシステムの改行シーケンス。
- pure nothrow @nogc @safe bool
isAlphaNum
(dcharc
); - Parameters:
dchar c
テストする文字。 Returns:アルファベットか数字か。c
が文字か数字か (0 ... 9, a ... z, A ... Z)。Examples:assert( isAlphaNum('A')); assert( isAlphaNum('1')); assert(!isAlphaNum('#')); // 注: ASCII以外のUnicode英数字に対してはtrueを返さない: assert(!isAlphaNum('á'));
- pure nothrow @nogc @safe bool
isAlpha
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:以下はc
がASCII文字(A .. Z, a .. z)であるかどうか。Examples:assert( isAlpha('A')); assert(!isAlpha('1')); assert(!isAlpha('#')); // 注: 非ASCIIのUnicodeアルファベット文字に対してはtrueを返さない: assert(!isAlpha('á'));
- pure nothrow @nogc @safe bool
isLower
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:以下はその例である。c
がASCIIの小文字(a .. z)であるかどうか。Examples:assert( isLower('a')); assert(!isLower('A')); assert(!isLower('#')); // 注: ASCII以外のUnicodeの小文字に対してはtrueを返さない assert(!isLower('á')); assert(!isLower('Á'));
- pure nothrow @nogc @safe bool
isUpper
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:以下はc
がASCIIの大文字(A .. Z)であるかどうか。Examples:assert( isUpper('A')); assert(!isUpper('a')); assert(!isUpper('#')); // 注: ASCII以外のUnicodeの大文字に対してはtrueを返さない assert(!isUpper('á')); assert(!isUpper('Á'));
- pure nothrow @nogc @safe bool
isDigit
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:を指定する。c
が数字 (0 ~ 9) かどうか。Examples:assert( isDigit('3')); assert( isDigit('8')); assert(!isDigit('B')); assert(!isDigit('#')); // 注: ASCII以外のUnicodeの数字に対してはtrueを返さない assert(!isDigit('0')); // 全角数字ゼロ(U+FF10) assert(!isDigit('4')); // 全角数字4(U+FF14)
- pure nothrow @nogc @safe bool
isOctalDigit
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:以下はc
が8進数(0~7)であるかどうか。Examples:assert( isOctalDigit('0')); assert( isOctalDigit('7')); assert(!isOctalDigit('8')); assert(!isOctalDigit('A')); assert(!isOctalDigit('#'));
- pure nothrow @nogc @safe bool
isHexDigit
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:以下はc
が16進数 (0 ... 9, A ... F, a ... f) であるかどうか。Examples:assert( isHexDigit('0')); assert( isHexDigit('A')); assert( isHexDigit('f')); // 小文字の16進数も受け付ける assert(!isHexDigit('g')); assert(!isHexDigit('G')); assert(!isHexDigit('#'));
- pure nothrow @nogc @safe bool
isWhite
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:が空白文字かどうか。c
が空白文字かどうか。これには 空白文字には、スペース、タブ、垂直タブ、フォームフィード、キャリッジリターン、ラインフィードが含まれる。 文字が含まれる。Examples:assert( isWhite(' ')); assert( isWhite('\t')); assert( isWhite('\n')); assert(!isWhite('1')); assert(!isWhite('a')); assert(!isWhite('#')); // 注: ASCII以外のUnicode空白文字に対してはtrueを返さない。 static import std.uni; assert(std.uni.isWhite('\u00A0')); assert(!isWhite('\u00A0')); // std.ascii.isWhite
- pure nothrow @nogc @safe bool
isControl
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:が制御文字かどうか。c
が制御文字かどうか。Examples:assert( isControl('\0')); assert( isControl('\022')); assert( isControl('\n')); // 改行は空白文字でもあり制御文字でもある assert(!isControl(' ')); assert(!isControl('1')); assert(!isControl('a')); assert(!isControl('#')); // 注: ASCII以外のUnicode制御文字は認識されない: assert(!isControl('\u0080')); assert(!isControl('\u2028')); assert(!isControl('\u2029'));
- pure nothrow @nogc @safe bool
isPunctuation
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:が句読点かどうか。c
が句読点文字かどうか。これには 制御文字、文字、数字、空白でないすべてのASCII文字が含まれる。 空白でないすべてのASCII文字が含まれる。Examples:assert( isPunctuation('.')); assert( isPunctuation(',')); assert( isPunctuation(':')); assert( isPunctuation('!')); assert( isPunctuation('#')); assert( isPunctuation('~')); assert( isPunctuation('+')); assert( isPunctuation('_')); assert(!isPunctuation('1')); assert(!isPunctuation('a')); assert(!isPunctuation(' ')); assert(!isPunctuation('\n')); assert(!isPunctuation('\0')); // 注: 非 ASCII Unicodeの句読点文字は認識されない。 assert(!isPunctuation('\u2012')); // (U+2012 = en-dash)
- pure nothrow @nogc @safe bool
isGraphical
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:テストする文字c
が であるかどうか。Examples:assert( isGraphical('1')); assert( isGraphical('a')); assert( isGraphical('#')); assert(!isGraphical(' ')); // 空白はグラフィカルではない assert(!isGraphical('\n')); assert(!isGraphical('\0')); // 注: Unicodeのグラフィカル・キャラクタはそのようにみなされない。 assert(!isGraphical('á'));
- pure nothrow @nogc @safe bool
isPrintable
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:テストする文字。c
が印字可能文字かどうか。 スペース文字も含む。Examples:assert( isPrintable(' ')); // 空白文字は表示可能である assert( isPrintable('1')); assert( isPrintable('a')); assert( isPrintable('#')); assert(!isPrintable('\0')); // 制御文字は表示できない // 注: 表示可能な非ASCIIユニコード文字は認識されない。 assert(!isPrintable('á'));
- pure nothrow @nogc @safe bool
isASCII
(dcharc
); - Parameters:
dchar c
テストするキャラクター。 Returns:テストする文字。c
がASCII文字セット内にあるかどうか。 の範囲にあるかどうか。Examples:assert( isASCII('a')); assert(!isASCII('á'));
- auto
toLower
(C)(Cc
)
if (is(C : dchar)); - ASCII文字を小文字に変換する。Parameters:
C c
暗黙的にdchar に変換する任意の型の文字。 組み込み型または組み込み型の列挙型の場合、"enum" が返される、 Unqual!(OriginalType!C) が返され、ユーザー定義型の場合は 型の場合は、dchar が返される。 Returns:対応する小文字は、もしc
が大文字の それ以外の場合はc
そのものである。Examples:writeln(toLower('a')); // 'a' writeln(toLower('A')); // 'a' writeln(toLower('#')); // '#' // 注: ASCII以外のユニコード大文字は変換されない。 writeln(toLower('Á')); // 'Á'
- auto
toUpper
(C)(Cc
)
if (is(C : dchar)); - ASCII文字を大文字に変換する。Parameters:
C c
暗黙のうちにdchar に変換するすべての型。 が返される、 Unqual!(OriginalType!C) が返される。 型の場合は、dchar が返される。 Returns:対応する大文字は、もしc
が小文字のASCII 文字、そうでなければc
そのものである。Examples:writeln(toUpper('a')); // 'A' writeln(toUpper('A')); // 'A' writeln(toUpper('#')); // '#' // 注: ASCII以外のユニコード小文字は変換されない。 writeln(toUpper('á')); // 'á'
Copyright © 1999-2024 by the D Language Foundation
DEEPL APIにより翻訳、ところどころ修正。
このページの最新版(英語)
このページの原文(英語)
翻訳時のdmdのバージョン: 2.108.0
ドキュメントのdmdのバージョン: 2.109.1
翻訳日付 :
HTML生成日時:
編集者: dokutoku