Subversion Repositories spacemission

Rev

Blame | Last modification | View Log | RSS feed

  1. unit MarkdownUnicodeUtils;
  2.  
  3. {
  4. Copyright (c) 2011+, Health Intersections Pty Ltd (http://www.healthintersections.com.au)
  5. All rights reserved.
  6.  
  7. Redistribution and use in source and binary forms, with or without modification,
  8. are permitted provided that the following conditions are met:
  9.  
  10.  * Redistributions of source code must retain the above copyright notice, this
  11.    list of conditions and the following disclaimer.
  12.  * Redistributions in binary form must reproduce the above copyright notice,
  13.    this list of conditions and the following disclaimer in the documentation
  14.    and/or other materials provided with the distribution.
  15.  * Neither the name of HL7 nor the names of its contributors may be used to
  16.    endorse or promote products derived from this software without specific
  17.    prior written permission.
  18.  
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
  20. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  23. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  24. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. POSSIBILITY OF SUCH DAMAGE.
  29. }
  30.  
  31. {$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
  32.  
  33. interface
  34.  
  35. uses
  36.   SysUtils;
  37.  
  38. {$IFNDEF FPC}
  39. type
  40.   UnicodeChar = char;
  41. {$ENDIF}
  42.  
  43. function unicodeChars(s : String) : TArray<UnicodeChar>;
  44.  
  45. implementation
  46.  
  47. {$IFDEF FPC}
  48.  
  49. function unicodeChars(s : String) : TArray<UnicodeChar>;
  50. var
  51.   i, l: integer;
  52.   us: UnicodeString;
  53. begin
  54.   us := UTF8Decode(s);
  55.   l := Length(us);
  56.   SetLength(result, l);
  57.   for i:=1 to l do result[i-1] := us[i];
  58. end;
  59.  
  60. {$ELSE}
  61.  
  62. function unicodeChars(s : String) : TArray<UnicodeChar>;
  63. var
  64.   i : Integer;
  65. begin
  66.   SetLength(result, length(s));
  67.   for i := 1 to length(s) do
  68.     result[i-1] := s[i];
  69. end;
  70.  
  71. {$ENDIF}
  72.  
  73. end.
  74.  
  75.