DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: xieqiongxi1
今日帖子: 0
在线用户: 4
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 tanyztj (tany) ★☆☆☆☆ -
普通会员
2019/12/26 5:09:05
标题:
初学delphi,请问前辈指教,谢谢!(问题:关于代码汉字变成#35745#31639#22120此类) 浏览:1167
加入我的收藏
楼主: 刚学时是能*.dfm文件是能正常显示中文汉字的,这几天学着学着,发现*.dfm文件的中文件部分汉字变成了#35745#31639#22120此类(汉字是“计算器”),那位前辈能清楚点请下如何回复正常,谢谢谢谢!
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2019/12/26 5:19:16
1楼: this is a representation in BINARY to your code non-ansi on DRM file!
But dont worry, because in your screen should be ok when running.

**********
HELP SYSTEM:  String Types (Delphi)

var
 S: string;

creates a variable S that holds a string. On the Win32 platform, the compiler interprets string (when it appears without a bracketed number after it) as UnicodeString. 

On the Win32 platform, you can use the {$H-} directive to turn string into ShortString. This is a potentially useful technique when using older 16-bit Delphi code or Turbo Pascal code with your current programs. 

Note that the keyword string is also used when declaring ShortString types of specific lengths (see Short Strings, below). 

Comparison of strings is defined by the ordering of the elements in corresponding positions. Between strings of unequal length, each character in the longer string without a corresponding character in the shorter string takes on a greater-than value. For example, 'AB' is greater than 'A'; that is, 'AB' > 'A' returns True. Zero-length strings represent the lowest values. 

You can index a string variable just as you would an array. If S is a non-UnicodeString string variable and i, an integer expression, S[i] represents the ith byte in S, which may not be the ith character or an entire character at all for a multibyte character string (MBCS). Similarly, indexing a UnicodeString variable results in an element that may not be an entire character. If the string contains characters in the Basic Multilingual Plane (BMP), all characters are 2 bytes, so indexing the string gets characters. However, if some characters are not in the BMP, an indexed element may be a surrogate pair - not an entire character. 

The standard function Length returns the number of elements in a string. As noted above, the number of elements is not necessarily the number of characters. The SetLength procedure adjusts the length of a string. Note that the SizeOf function returns the number of bytes used to represent a variable or type. Note that SizeOf returns the number of characters in a string only for a short string. SizeOf returns the number of bytes in a pointer for all other string types, since they are pointers. 

For a short string or AnsiString, S[i] is of type AnsiChar. For a WideString, S[i] is of type WideChar. For single-byte (Western) locales, MyString[2] := 'A'; assigns the value A to the second character of MyString. The following code uses the standard UpCase function to convert MyString to uppercase: 

var I: Integer;
begin
  I := Length(MyString);
  while I > 0 do
  begin
    MyString[I] := UpCase(MyString[I]);
    I := I - 1;
  end;
end;
Be careful indexing strings in this way, since overwriting the end of a string can cause access violations. Also, avoid passing string indexes as var parameters, because this results in inefficient code. 

You can assign the value of a string constant - or any other expression that returns a string - to a variable. The length of the string changes dynamically when the assignment is made. Examples: 

MyString := 'Hello world!';
MyString := 'Hello' + 'world';
MyString := MyString + '!';
MyString := ' '; { space }
MyString := '';  { empty string }

**********
System.UnicodeString Type:

UnicodeString is the C++ analog for the Delphi UnicodeString type. 

Delphi utilizes several string types. UnicodeString can contain both Unicode and ANSI strings, ANSI strings being converted first. Support for this type includes the following features: 

Strings as large as available memory. 
Efficient use of memory through shared references. 
Routines and operators that evaluate strings based on the current locale.
UnicodeString variables that have not been assigned an initial value contain a zero-length string. 

Note: Delphi also supports UnicodeString, but implements it as a primitive type rather than a class. By default, variables declared as type String are UnicodeString. 
String indexes are 1-based in desktop platforms and 0-based in mobile platforms. For more information, see Migrating Delphi Code to Mobile from Desktop. 

Tip: You can go through the values of a string without specifying any index. In Delphi, use for … in. In C++, you can use range-based for loops (only with Clang-enhanced C++ compilers) and STL iterators to go through the values of a string without specifying any index.
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 tanyztj (tany) ★☆☆☆☆ -
普通会员
2019/12/26 8:44:22
2楼: 谢谢您的回复,嗯,我现在是个初学者,所以,如果有办法可以将此类代码再转回汉字,我将能更容易看懂,更容易学习,因为我发现不单是我学的的代码*.dfm变了,并且一个教程中的源码也变成这样,所以,如果有办法可以转回来了,还请您或者其它的前辈告知详细方法,不胜感谢!谢谢前辈!
----------------------------------------------
-
作者:
男 sail2000 (小帆工作室) ★☆☆☆☆ -
盒子活跃会员
2019/12/26 8:52:55
3楼: 这个是delphi6時候的问题了,#后面是数字,其实就是汉字的Unicode编码,那么现在问题就是怎么将 unicode 编码转为汉字显示了。。。

最后,dfm中的源代码一般不需要手动编译。。。
----------------------------------------------
delphi 是兴趣,和工作无关,即使它倒闭。又不靠它 delphi 吃饭,怕甚?
作者:
男 flyhorsefj (pegasus) ★☆☆☆☆ -
普通会员
2019/12/26 8:55:07
3楼: 窗体上鼠标右键 View as Text,就可以看到窗体里的汉子了
dfm代码编辑再续表右键 View as Form 可恢复
此帖子包含附件:
PNG 图像
大小:128.5K
----------------------------------------------
-
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2019/12/26 10:04:07
4楼: Try this site to know how will be your Chinese Text in Decimal coding:

Chinese to UniCode / UniCode to Chinese
https://www.chinese-tools.com/tools/converter-unicode.html

http://www.pinyin.info/tools/converter/chars2uninumbers.html


按此在新窗口浏览图片


Now try this function: See your HELP about "UTF-8 Conversion Routines"
-  System.AnsiToUtf8()
-  System.Utf8ToAnsi()


Download this PDF to more info: 
 http://www.unicode.org/versions/Unicode5.2.0/ch04.pdf


按此在新窗口浏览图片


dont worry!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 vclclx (vclclx) ★☆☆☆☆ -
普通会员
2019/12/26 10:56:33
5楼: Delphi本身的问题,dfm文件即使是存成utf8格式的,汉字也存成#后面带Unicode编码表示的字符串,而不是直接的汉字字符。这在Delphi2009支持Unicode以前可以理解,但以后仍然是这种方式就令人难以接受。如果你打开一个VB窗体文件,里面的窗体上的元素如果有汉字就会是汉字字符,不会以字符串里的转换码显示。
----------------------------------------------
-
作者:
男 sun2grit (Asun) ★☆☆☆☆ -
盒子活跃会员
2019/12/26 15:38:25
6楼: 学习了
----------------------------------------------
家具安装 万师傅家具安装平台 安装维修师傅黄页 一键式测量仪
作者:
男 biznow (biznow) ★☆☆☆☆ -
盒子活跃会员
2019/12/26 16:15:59
7楼: 当你知道编译好的可执行文件中含有dfm的全部信息,你就知道这根本不是问题,跟是不是unicode完全没有关系,你要知道,系统上为了保持一直,这个是很好的方法


可执行程序生成之后,可以运行在各种语言环境
----------------------------------------------
-
作者:
男 tanyztj (tany) ★☆☆☆☆ -
普通会员
2019/12/26 16:32:20
8楼: 谢谢:flyhorsefj,也谢谢回复的各位,flyhorsefj贴子为简单正确方法,再次感谢。
----------------------------------------------
-
作者:
男 vclclx (vclclx) ★☆☆☆☆ -
普通会员
2019/12/26 17:30:41
9楼: 这个事情的问题在于,如果你想打开dfm文件直接编辑,利用文字编辑器的查找替换等功能,在有中文存在时是一件很费力的事情。你只能在编辑器里面用图形界面的方式,在对象检视器里修改。固然,这个确实保持了早期版本和现在Unicode版本的一致性,但是它确实没有改进。关于在各种语言环境里运行,这本来就是Unicode的好处啊,非Unicode程序是需要根据编译时的语言在操作系统里选择区域设置,否则就显示乱码,不同语言要编译出多种程序。

Pas文件里面可以直接有汉字字符,如果显示成#+Unicode编码的形式,我估计所有程序员都得崩溃;但dfm文件却不能直接用汉字字符,这不能不说是一种很奇葩的事情。
----------------------------------------------
-
作者:
男 xlonger (xlonger) ★☆☆☆☆ -
普通会员
2019/12/27 7:17:30
10楼: 估计是历史遗留问题了。
----------------------------------------------
我打的是酱油,而不是别的什么油。
我灌的是口水,而不是别的什么水。
我聊的折腾不是那个不折腾的折腾。
我说的阿娇不是那个邓玉娇的阿娇。
3个代表,6个为什么,9个肠胃炎。
D性强的领导干部都不喜欢热比娅。
我特别要讲的是,屁民网黄色论坛是我经常上网必选的 网站之一
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行109.8633毫秒 RSS