::: µ¨ÆÄÀÌ Tip&Trick :::

µ¨ÆÄÀÌ Tip&Trick ¼º°Ý¿¡ ¸ÂÁö ¾Ê´Â ±¤°í,ºñ¹æ,Áú¹®ÀÇ ±ÛÀº Áï½Ã »èÁ¦Çϸç
³»¿ëÀ» º¹»çÇÏ¿© »ç¿ëÇÒ °æ¿ì ¹Ýµå½Ã ÀÌ°÷(http://www.howto.pe.kr)À» Ãâó·Î ¸í½ÃÇÏ¿© ÁÖ¼¼¿ä


Category

  ±è¿µ´ë(2003-03-07 09:12:17, Hit : 5083, Vote : 1469
 WideString À» String À¸·Î ¹Ù²Ù±â

uses sysutils, windows;

const Ccol = 24;

function ansiToWide(s: String): pWideChar;
var
  wideStrSize: integer;
  j: integer;
  p: pChar absolute result;
begin
  wideStrSize := 2*(length(s)+1);
  getmem(result, wideStrSize);
  stringToWideChar(s, result, wideStrSize);
end;

function wideAsString(p: pWideChar): String;
var
  wideStrSize: integer;
  j: integer;
begin
  wideStrSize := 2*lstrlenw(p);
  setLength(result, wideStrSize);
  move(p[0], result[1], wideStrSize);
end;

function widePos(sKey, sTarget: String): integer;
begin
  result := (pos(sKey, sTarget) + 1) div 2;
end;

procedure checkMargin(j: integer);
const
  Cline = (80-Ccol) div 3;
begin
  if j mod Cline = 0 then
  begin
    writeln;
    write(' ': Ccol);
  end;
end;

procedure showAnsi(s: String);
var
  j: integer;
begin
  writeln('Ansi string: ':Ccol, s);
  write('Ansi bytes: ':Ccol);
  for j := 1 to length(s) do
  begin
    checkMargin(j);
    write (ord(s[j]), ' ');
  end;
  writeln;
end;


Procedure showUnicode(p: PwideChar);
Var
  j: integer;
Begin
  write('Unicode bytes: ':Ccol);
  for j:=0 to 2*lstrLenw(p)+1 do begin
      checkMargin(j+1);
      write (ord(pchar(p)[j]), ' ');
      end;
  writeln;
End;

Procedure showWideString(s: string);
Var
  j: integer;
Begin
  write('Wide-as-string bytes: ':Ccol);
  for j:=1 to length(s) do begin
      checkMargin(j);
      write (ord(s[j]), ' ');
      end;
  writeln;
End;


Var
  s1, s2, s1w, s2w: string;
  p1, p2: pWideChar;
  n: integer;
  f: file;
Begin
  s1:='abcdefghijklm';
  s2:='ef';
  p1:=ansiToWide(s1);
  p2:=ansiToWide(s2);
  s1w:=wideAsString(p1);
  s2w:=wideAsString(p2);

  showAnsi(s1);
  showUnicode(p1);
  showWideString(s1w);
  writeln;

  showAnsi(s2);
  showUnicode(p2);
  showWideString(s2w);
  writeln;

  writeln('String pos: ':Ccol, pos(s2, s1));
  writeln('Wide-string pos: ':Ccol, widePos(s2w, s1w));
  writeln;

  freemem(p1);
  freemem(p2);

  write('String to put in Test.txt: ');
  readln(s2);
  p2:=ansiToWide(s2);
  s2w:=wideAsString(p2);
  write('Position to put it at (from 0): ');
  readln(n);

  assignFile(f, 'test.txt');
  reset(f, 1);
  seek(f, n);

  blockWrite(f, p2[0], 2*lstrLenw(p2));
  close(f);

  reset(f, 1);
  setLength(s1, fileSize(f));
  blockRead(f, s1[1], length(s1));
  close(f);

  writeln('Pos of ', s2, ' in Text.txt = ', pos(s2w, s1)-1);

  freemem(p2);
end.





571   [À©µµ¿ìÁî API] À©µµ¿ìÁî '½ÃÀÛ' ¸Þ´º Refresh ½ÃÅ°±â  ±è¿µ´ë 2003/03/07 5191 1547
570   [À©µµ¿ìÁî API] ´Ù¸¥ ApplicationÀÇ È­¸é¿¡ ±ÛÀÚ,±×¸²À» Ãâ·ÂÇÏ±â  ±è¿µ´ë 2003/03/07 3847 991
  [ÀϹÝ/ÄÄÆ÷³ÍÆ®] WideString À» String À¸·Î ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 5083 1469
568   [À©µµ¿ìÁî API] À©µµ¿ìÁî Ž»ö±âÀÇ ÆÄÀÏ, ÄÄÇ»ÅÍ Ã£±â È­¸é ¶ç¿ì±â  ±è¿µ´ë 2003/03/07 6762 1780
567   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] MessageDlg()ÀÇ ÆùÆ®¸¦ ¹Ù²Ù¾î¼­ ¶ç¿ì±â  ±è¿µ´ë 2003/03/07 4335 1166
566   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ListView ÀÇ item À» °­Á¦·Î ÆíÁý»óÅ·Π¸¸µé±â  ±è¿µ´ë 2003/03/07 5732 1346
565   [µ¥ÀÌÅͺ£À̽º] µ¿ÀûÀ¸·Î SELECTÀÇ GROUP BY ¹® ¸¸µé±â  ±è¿µ´ë 2003/03/07 4616 1033
564   [À©µµ¿ìÁî API] ALT_F4 hot key °¡·Îä±â  ±è¿µ´ë 2003/03/07 6156 1760
563   [À©µµ¿ìÁî API] ·¹Áö½ºÆ®¸® Àüü °Ë»öÇÏ±â  ±è¿µ´ë 2003/03/07 4733 1243
562   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TOpenDialog ÀÇ '¼±ÅÃ','Ãë¼Ò' ¹öÆ° À̸§ ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 4749 1436
561   [À©µµ¿ìÁî API] ¸ð¼­¸®°¡ µÕ±Ù(rounded ends) TEdit ¸¸µé±â  ±è¿µ´ë 2003/03/07 5593 1412
560   [½Ã½ºÅÛ] ÇÁ·Î±×·¥ÀÌ µ¿ÀûÀ¸·Î ÇÒ´ç¹ÞÀº ¸Þ¸ð¸® Å©±â ?  ±è¿µ´ë 2003/03/07 4987 1416
559   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] OnActivate À̺¥Æ® ³»¿¡¼­ Æû È®½ÇÈ÷ ´Ý±â  ±è¿µ´ë 2003/03/07 4613 1179
558   [µ¥ÀÌÅͺ£À̽º] QueryÇÑ °á°ú¸¦ ¼öÁ¤Çϱâ...  ±è¿µ´ë 2003/03/07 5321 1302
557   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] StringGridÀÇ CellÀ» °­Á¦·Î ´ÙÁß ¼±ÅÃ/ÇØÁ¦ ½ÃÅ°±â  ±è¿µ´ë 2003/03/07 4515 1110
556   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TRichEditÀÇ Çà°£°Ý ¶ç¿ì±â(line spacing)  ±è¿µ´ë 2003/03/07 5958 1589
555   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ÇÁ¸°ÅÍ·Î escape ¹®ÀÚ Ãâ·ÂÇϱâ(raw print)  ±è¿µ´ë 2003/03/07 6544 1453
554   [À©µµ¿ìÁî API] keyboard, mouse ¸Þ½ÃÁö ¹«½Ã(skip) ÇÏ±â  ±è¿µ´ë 2003/03/07 4910 1314
553   [À©µµ¿ìÁî API] À©µµ¿ìÁî Ä¿¼­(global cursor) ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 7739 2385
552   [½Ã½ºÅÛ] ÇöÀç ÇÁ¸°ÅÍÀÇ Ãâ·Â°¡´ÉÇÑ ¿ëÁöÁ¾·ù ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 6765 1797
551   [½Ã½ºÅÛ] ÇÁ¸°ÅÍ¿¡ ÀÛ¾÷ÁßÀÎ jobÀÇ ¸®½ºÆ® ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 5361 1351
550   [½Ã½ºÅÛ] Clipboard ÈÉÃ帱â(Clipboard hooking)  ±è¿µ´ë 2003/03/07 7517 1724
549   [À©µµ¿ìÁî API] ControlÀÇ repainting ±ÝÁöÇÏ¿© ±ô¹ÚÀÓ ÁÙÀÌ±â  ±è¿µ´ë 2003/03/07 6336 1386
548   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¹®ÀÚ¿­ÀÇ ³¡¿¡¼­ºÎÅÍ °Ë»öÇÏ´Â Pos() ÇÔ¼ö  ±è¿µ´ë 2003/03/07 5529 1284
547   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] µð·ºÅ丮¸í ¹Ù²Ù±â/À̵¿ ÇÏ±â  ±è¿µ´ë 2003/03/07 5782 1705
546   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] µð·ºÅ丮 º¯µ¿»çÇ×À» Ž»ö±â¿¡ ¾Ë¸®±â  ±è¿µ´ë 2003/03/07 5872 1709
545   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Æû ÀμâÇϱâ 2  ±è¿µ´ë 2003/03/07 4279 1365
544   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¿¬¼ÓµÈ Å°º¸µåÀÇ Å° ¹ß»ý½ÃÅ°±â  ±è¿µ´ë 2003/03/07 4729 1220
543   [½Ã½ºÅÛ] Keyboard Hook  ±è¿µ´ë 2003/03/07 5294 1000
542   [À©µµ¿ìÁî API] ·¹Áö½ºÆ®¸®ÀÇ Æ¯Á¤Å°¸¦ ÆÄÀÏ·Î ÀúÀå/º¹¿øÇÏ±â  ±è¿µ´ë 2003/03/07 7229 1649
541   [½Ã½ºÅÛ] PC¿¡ ¼³Ä¡µÈ DirectX ¹öÀü ÀÐ±â  ±è¿µ´ë 2003/03/07 4351 1326
540   [µ¥ÀÌÅͺ£À̽º] CD ¿¡ ÀÖ´Â DB Á¢±ÙÇÏ±â  ±è¿µ´ë 2003/03/07 4198 1187
539   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Á¦¾îÆÇÀÇ applet ¸®½ºÆ® (17°³)  ±è¿µ´ë 2003/03/07 3723 1069
538   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Åõ¸íÇÑ Bitmaps ÀÎ¼â  ±è¿µ´ë 2003/03/07 8017 1556
537   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] QReport ¸¦ bmp ·Î º¯È¯ÇÏ±â  ±è¿µ´ë 2003/03/07 3650 946
536   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] WMF ¸¦ BMP ·Î º¯È¯ÇÏ±â  ±è¿µ´ë 2003/03/07 4778 1455
535   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] MemoÀÇ ÀÔ·ÂÇà¼ö Á¦ÇÑÇÏ±â  ±è¿µ´ë 2003/03/07 4544 1265
534   [½Ã½ºÅÛ] PCÀÇ Àü¿ø»óÅ ¾Ë¾Æº¸±â  ±è¿µ´ë 2003/03/07 6296 3831
533   [À©µµ¿ìÁî API] ÆÄÀÏ¿¡¼­ ¾ÆÀÌÄÜ »©³»±â(32 * 32)  ±è¿µ´ë 2003/03/07 6843 1725
532   [À©µµ¿ìÁî API] ÆÄÀÏ¿¡¼­ ¾ÆÀÌÄÜ »©³»±â(16 * 16)  ±è¿µ´ë 2003/03/07 5229 1380

[ÀÌÀü 10°³] [1].. 11 [12][13][14][15][16][17][18][19][20]..[25] [´ÙÀ½ 10°³]
 

Copyright 1999-2024 Zeroboard / skin by zero