Originale-mail to me for new edition

 

Handling null-terminated strings

 

Object Pascal’s extended syntax allows the Read, Readln, Str, and Val standard procedures to be applied to zero-based character arrays, and allows the Write, Writeln, Val, AssignFile, and Rename standard procedures to be applied to both zero-based character arrays and character pointers. In addition, the following functions are provided for handling null-terminated strings. For more information about null-terminated strings, see Working with null-terminated strings.

 

Function

Description

StrAlloc

Allocates a character buffer of a given size on the heap.

StrBufSize

Returns the size of a character buffer allocated using StrAlloc or StrNew.

StrCat

Concatenates two strings.

StrComp

Compares two strings.

StrCopy

Copies a string.

StrDispose

Disposes a character buffer allocated using StrAlloc or StrNew.

StrECopy

Copies a string and returns a pointer to the end of the string.

StrEnd

Returns a pointer to the end of a string.

StrFmt

Formats one or more values into a string.

StrIComp

Compares two strings without case sensitivity.

StrLCat

Concatenates two strings with a given maximum length of the resulting string.

StrLComp

Compares two strings for a given maximum length.

StrLCopy

Copies a string up to a given maximum length.

StrLen

Returns the length of a string.

StrLFmt

Formats one or more values into a string with a given maximum length.

StrLIComp

Compares two strings for a given maximum length without case sensitivity.

StrLower

Converts a string to lowercase.

StrMove

Moves a block of characters from one string to another.

StrNew

Allocates a string on the heap.

StrPCopy

Copies a Pascal string to a null-terminated string.

StrPLCopy

Copies a Pascal string to a null-terminated string with a given maximum length.

StrPos

Returns a pointer to the first occurrence of a given substring within a string.

StrRScan

Returns a pointer to the last occurrence of a given character within a string.

StrScan

Returns a pointer to the first occurrence of a given character within a string.

StrUpper

Converts a string to uppercase.

 

Standard string-handling functions have multibyte-enabled counterparts that also implement locale-specific ordering for characters. Names of multibyte functions start with Ansi-. For example, the multibyte version of StrPos is AnsiStrPos. Multibyte character support is operating-system dependent and based on the current locale.

 

Wide-character strings

The System unit provides three functions, WideCharToString, WideCharLenToString, and StringToWideChar, that can be used to convert null-terminated wide character strings to single- or double-byte long strings.

For more information about wide-character strings, see About extended character sets.

 

Topic groups

 

See also

Standard routines and I/O: Overview

 

 

译文

 

处理空结束串

 

Object Pascal扩展语法允许ReadReadlnStrVal等标准过程适用于零基字符数组,允许WriteWritelnValAssignFileRename等标准过程适用于零基字符数组和字符指针。另外,还提供下列函数来处理空结束串。关于空结束串的更多信息,见空结束串

 

函数

描述

StrAlloc

在堆中分配给定尺寸的字符缓冲区

StrBufSize

返回用StrAllocStrNew分配的字符缓冲区的尺寸

StrCat

连接两个串

StrComp

比较两个串

StrCopy

复制一个串

StrDispose

释放用StrAllocStrNew分配的字符缓冲区

StrECopy

复制串并返回串尾指针

StrEnd

返回串尾指针

StrFmt

格式化一个或多个值到一个串中

StrIComp

比较两个串(大小写不敏感)

StrLCat

连接两个串(给定结果串的最大长度)

StrLComp

比较两个串(给定最大长度)

StrLCopy

复制串直到给定的最大长度

StrLen

返回串的长度

StrLFmt

格式化一个或多个值到一个串中(给定串的最大长度)

StrLIComp

比较两个串(给定最大长度且大小写不敏感)

StrLower

转换一个串到小写

StrMove

从一个串移动字符块到另一个串

StrNew

在堆中分配串

StrPCopy

复制一个Pascal串到一个空结束串

StrPLCopy

复制一个Pascal串到一个空结束串(给定最大长度)

StrPos

返回给定子串在串中第一次出现的位置指针

StrRScan

返回给定字符在串中最后一次出现的位置指针

StrScan

返回给定字符在串中第一次出现的位置指针

StrUpper

转换一个串到大写

 

标准的串处理函数还有相应支持多字节的函数,用于实现特定场所的字符命令。多字节函数的名称以Ansi-开始。例如,StrPos的多字节版本是AnsiStrPos。多字节字符的支持取决于操作系统,并且基于当前场所。

 

宽字符串

System单元提供了三个函数,WideCharToStringWideCharLenToStringStringToWideChar,它们用于转换空结束的宽字符串到单字节或双字节的长串。

有关宽字符串的更多信息,见关于扩展字符集

 

主题组

 

相关主题

标准例程和I/O:概述