CHMlib Logo Leading Translation Management System for Translation Agencies, Top Translation Management Software for Freelance Translators, Time Tracking Software, Word Count, Character Count and Line Count Software, Computer Assisted Translation Tool for Easy Word Count, Clipboard Character Count Software, User-Friendly Translation Memory Software, Terminology Management Software, Terminology Management Server, Microsoft Glossary Software, Dictionary of Acronyms, Social Network for Translators and Translation Agencies, Acronyms and Abbreviations Search Engine, Russian Translation Lab, Ukrainian Translation Lab.
You are reading help file online using chmlib.com
CrisisHelper - First Aid in Tough Times of World Economic Crisis


CharLength

Prototype:

function CharLength(const S: String; const Index: Integer): Integer;

Description:

Returns the length in bytes (1 or 2) of the character in the specified string at the specified index.

Remarks:

In double-byte character sets (Chinese, Japanese, Korean), most non-ASCII characters occupy two bytes. Note that the second byte of a double-byte character -- known as the "trail byte" -- can be in the same range used by ASCII characters (below 128). Thus, when stepping through a string that may contain double-byte characters, such as a path or filename, care must be taken to not mistake trail bytes for single-byte ASCII characters.

Example:
function BackslashToSlash(const S: String): String;
var
  I: Integer;
begin
  Result := S;
  I := 1;
  while I <= Length(Result) do
  begin
    if Result[I] = '\' then
      Result[I] := '/';
    // Go to the next character. But do not simply increment I by 1.
    // Increment by CharLength() in case Result[I] is a double-byte character.
    I := I + CharLength(Result, I);
  end;
end;

...

begin
  // Show path of Common Files with backslashes changed to forward slashes
  MsgBox(BackslashToSlash(ExpandConstant('{cf}')), mbInformation, MB_OK);
end;


You are reading help file online using chmlib.com

If you want your help file to be removed or added please send e-mail to chmlibcom@gmail.com
Partner sites: Logo Design, Simple Anti-Crisis Accounting Software, Voice Search for Web