Forum > General
IsApostrophe anyone?
dbannon:
Egan, not wanting to mess with your day. But I just answering a post in a different thread and realised I did something you might not like. I wanted to indicate I was talking about multiple ppu files. And did what is quite common (but incorrect) :
ppu's
Thats neither quote nor apostrophe, its bad grammar but people do it. And the English language is an evolving language.
Davo
Thaddy:
Anyway, I debugged my charinset overloads, which are really string in set of string overloads:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program untitled;{$mode delphi}{$H+}{$codepage utf8}uses sysutils;// utf8 charinsetfunction CharInSet(const C: UTF8String; const CharSet: array of UTF8String): Boolean;overload;var I: Integer; FirstChar: UTF8String; Len: Integer;begin Result := False; if C = '' then Exit; // Get the first UTF-8 character properly // imho better than the UTF8CodepointToUnicode way Len := 1; case Byte(C[1]) of $C2..$DF: Len := 2; // 2-byte UTF-8 $E0..$EF: Len := 3; // 3-byte UTF-8 $F0..$F4: Len := 4; // 4-byte UTF-8 end; // Extract first UTF-8 character FirstChar := Copy(C, 1, Len); // Check against character set // Check against character set for I := Low(CharSet) to High(CharSet) do if FirstChar = CharSet[I] then Exit(True);end; // Or for UnicodeCharfunction CharInSet(const C: UnicodeString; const CharSet: array of UnicodeString): Boolean;overload;var I: Integer;begin Result := False; Result := False; for I := Low(CharSet) to High(CharSet) do if C = CharSet[I] then Exit(True);end; var ch: utf8string = '😊'; a: array of utf8String; ch2: UnicodeString = '😀'; a2: array of UnicodeString; begin a := ['😀', '😊', '👍']; if CharInSet(ch,a) then WriteLn('Surrogate pair character found:',ch); a2 := ['😀', '😊', '👍']; if CharInSet(ch2,a2) then WriteLn('Surrogate pair character found:',ch);end.Don't forget the {$codepage UTF8} because of the string literals.
The highlighter changed the literals - see screenshot - , so I attach the program code:
EganSolo:
Thaddy,
Thank you very much for this code. It helped quite a bit! Much appreciate it!
Navigation
[0] Message Index
[*] Previous page