|
Переход с 5 на 6 Builder (проблема с хинтами)
#33687032
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
Ссылка на профиль пользователя:
|
Участник
Откуда: Караганда -> Липецк
Сообщения: 813
|
|
ElenaVEКак сделать, чтобы при открытии и сохранении dfm, строки не сохранялись в UNICODE?
Можно воспользоватся конвертором. который юникод обратно конвертит
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. 165. 166. 167. 168. 169. 170. 171. 172. 173. 174. 175. 176. 177. 178. 179. 180. 181. 182. 183. 184. 185. 186. 187. 188. 189. 190. 191. 192. 193.
(******************************************************************************)
(* dfmcnv.dpr *)
(* DFM conversion utility *)
(* Author: Nikolai Adrianov *)
(* *)
(* v1. 00 04 / 05 / 2004 *)
(* Initial version *)
(* *)
(******************************************************************************)
program dfmcnv;
{$APPTYPE CONSOLE}
uses
SysUtils;
type
TConvertorState = (csNormal, csBehindSharp, csInsideQuotes);
procedure ConvertLine(var LineIn, LineOut: String);
var
Ch: Char;
Hex: String;
State: TConvertorState;
i: Integer;
begin
State := csNormal;
Hex := '';
LineOut := '';
i := 1 ;
while i <= Length(LineIn) + 1 do begin
Ch := LineIn[i];
case (State) of
csNormal:
if Ch = '#' then begin
State := csBehindSharp;
LineOut := LineOut + '''';
Inc(i);
end else if Ch = '''' then begin
State := csInsideQuotes;
LineOut := LineOut + Ch;
Inc(i);
end else begin
LineOut := LineOut + Ch;
Inc(i);
end;
csInsideQuotes:
if Ch = '''' then begin
if LineIn[i + 1 ] = '''' then begin
LineOut := LineOut + Ch + Ch;
Inc(i, 2 );
end else if LineIn[i + 1 ] = '#' then begin
State := csBehindSharp;
Inc(i, 2 );
end else begin
State := csNormal;
LineOut := LineOut + Ch;
Inc(i);
end;
end else begin
LineOut := LineOut + Ch;
Inc(i);
end;
csBehindSharp:
if Ch in ['0'..'9'] then begin
Hex := Hex + Ch;
Inc(i);
end else begin
LineOut := LineOut + String(WideChar(StrToInt(Hex)));
Hex := '';
if Ch = '''' then begin
State := csInsideQuotes;
Inc(i);
end else if Ch = '#' then begin
State := csBehindSharp;
Inc(i);
end else begin
State := csNormal;
LineOut := LineOut + '''' + Ch;
Inc(i);
end;
end;
end;
end;
SetLength(LineOut, Length(LineOut) - 1 );
end;
procedure ConvertFile(FileNameIn, FileNameOut: String);
var
FileIn, FileOut: TextFile;
LineIn, LineOut: String;
begin
AssignFile(FileIn, FileNameIn);
Reset(FileIn);
try
AssignFile(FileOut, FileNameOut);
Rewrite(FileOut);
try
while not EOF(FileIn) do begin
Readln(FileIn, LineIn);
ConvertLine(LineIn, LineOut);
Writeln(FileOut, LineOut);
end;
finally
CloseFile(FileOut);
end;
finally
CloseFile(FileIn);
end;
end;
procedure ProcessFile(FileName: String);
begin
Writeln('Processing file: ' + FileName);
ConvertFile(FileName, FileName + '.d5');
DeleteFile(FileName);
RenameFile(FileName + '.d5', FileName);
end;
procedure ProcessDir(DirName: String);
var
sr: TSearchRec;
begin
Writeln('Processing directory: ' + DirName);
if FindFirst(DirName + '\*.dfm', $7FFFFFFF, sr) = 0 then begin
try
repeat
ProcessFile(DirName + '\' + sr.Name);
until FindNext(sr) <> 0 ;
finally
FindClose(sr);
end;
end;
end;
procedure Usage;
begin
Writeln('Usage: dfmcnv.exe [-f<filename>|-d<dirname>|-c|-?]');
Writeln(' f - converts specified DFM file');
Writeln(' d - converts all DFM''s in the directory');
Writeln(' c - converts all DFM''s in the *current* directory');
Writeln(' ? - displays this help.');
end;
var
i: Integer;
Flag: Char;
Param, FileName, DirName: String;
begin
Writeln('DFM conversion utility. (c) Nikolai Adrianov, 2004');
try
for i := 1 to ParamCount do begin
Param := ParamStr(i);
if (Length(Param) < 2 ) or
((Param[ 1 ] <> '-') and (Param[ 1 ] <> '/')) then
begin
Writeln(Format('Incorrect parameter #%d: %s'# 13 # 10 , [i, Param]));
Usage;
ExitCode := - 1 ;
Exit;
end;
Flag := Param[ 2 ];
Delete(Param, 1 , 2 );
case Flag of
'f':
FileName := ExpandFileName(Param);
'd':
DirName := ExpandFileName(Param);
'c':
DirName := GetCurrentDir;
'?', 'h':
begin
Usage;
ExitCode := 0 ;
Exit;
end;
end;
end;
if FileName <> '' then begin
ProcessFile(FileName);
end else if DirName <> '' then begin
ProcessDir(DirName);
end else begin
Writeln('No file or directory name specified.'# 13 # 10 );
Usage;
ExitCode := - 1 ;
Exit;
end;
except on E: Exception do
Writeln(E.Message);
end;
end.
|
|
|