TStringDynArray 动态数组  字符串 分解 分割  System::DynamicArray<System::UnicodeString>

TByteDynArray,    (TIdBytes)    String  相互转换  DynamicArray<System::Byte>

TIdBytes = array of Byte;

TByteDynArray;

Delphi   type TByteDynArray = array of Byte;

TByteDynArray defines a dynamic array of byte elements. You must use SetLength to allocate storage for such an array.

typedef DynamicArray<Byte>            TByteDynArray;
TBytes,就是 typedef System::DynamicArray<System::Byte> TBytes;

TBytes和TByteDynArray 是等价的。

数组

System::DynamicArray<int> array { 1, 2, 3, 4, 5};

DynamicArray<int> aint;
aint.Low;
aint.High;
aint[];
  1. arrayOfInt.Length = 10;
int total=;
for (int i=aint.Low; i<=aint.High; i++)
total += aint[i];
return total
SplitString 函数
#include <System.StrUtils.hpp>
TStringDynArray __fastcall SplitString(UnicodeString S, UnicodeString Delimiters);
和stringList的Delimiter一样,空格也分割了。

TByteArray 

#include <System.StrUtils.hpp>
#include <System.SysUtils.hpp>
 
TStringDynArray ls; 
ls = SplitString("a|b|c","|");
for(int i = ; i < ls .Length; i++)
ShowMessage(ls [i]);     TStringDynArray sarr;
    TStringList *ls = new TStringList();
    ls->Text = "a|b|c";
    sarr = ls->ToStringArray();
    delete ls; //String <==> TByteDynArray
String str;
str="abc";
    TByteDynArray barr;
    barr = str.BytesOf(); bytes=System::Sysutils::BytesOf(Caption);
bytes=System::Sysutils::WideBytesOf(Caption); Caption = System::Sysutils::StringOf(barr);
Caption = System::Sysutils::WideStringOf(barr);

TBytes bytes;

TByteDynArray barr;

String str;

str = Memo1->Text;

barr = str.BytesOf();

bytes = BytesOf(str);

bytes = WideBytesOf(str);

bytes = barr;

ExtractStrings

int __fastcall ExtractStrings(const System::Sysutils::TSysCharSet &Separators, const System::Sysutils::TSysCharSet &WhiteSpace, System::WideChar * Content, TStrings* Strings);

TStringDynArray  ar;  ar[0]=2;  ar[25]="";  ar.set_length(28);  ar[0]=2;  ar.Length;

用指定的字符串分割,空格可以不分割!

  ExtractStrings([';',',',':'],['#',' '],PChar(s),List);
  //第一个参数是分隔符; 第二个参数是开头被忽略的字符
  1. TStringDynArray arr;
  2. arr = System::Ioutils::TDirectory::GetFiles("C:\\Windows");
  3. this->Memo1->Lines->AddStrings(arr);
	TStringDynArray arr;
arr = System::Ioutils::TDirectory::GetFiles("C:\\Windows");
this->Memo1->Lines->AddStrings(arr);
  1. arr = System::Ioutils::TDirectory::GetFiles("c:\\windows","*.ppt", System::Ioutils::TSearchOption::soAllDirectories );
 for I := 0 to Length(LList) - 1 do
mmResults.Lines.Add(LList[I]);
 

Delphi 推荐用这个方法

astr:string;
  list: TArray<string>;
  list := astr.Split(['|']);
  list[0],list[1]...

for i := 0 to High(Editors) do

list[i]

for s in list

showmessage(s);

Split 是 delphi的函数,c++没有。TStringHelper = record helper for string

TStringList好用的特性
ss:TStringList;
begin
ss.AddPair('p1','aaaaa');
ss.AddPair('p2','bbbbb');
ss.Values['p1'];
ss.Values['p2'];

这样的效果

p1=aaaaa
p2=bbbbb

取p1的值aaaa

ss.Values['p1'];

st.Split([','],TStringSplitOptions.ExcludeEmpty);
CommaText甚是方便
TStrings.CommaText
aa
bb
cc
返回值 aa,bb,cc TStringList分割字符
新属性StrictDelimiter精确分割,空格不在分割换行了。         slsub->StrictDelimiter=true;
        slsub->Delimiter = awchar;
        slsub->DelimitedText = str; 拼接
list:TStringList;
Result := string.Join('|',List.ToStringArray) ;

XE4 TStringDynArray 比 c6 的TStringList 好用 字符串 分解 分割 转换 TByteDynArray的更多相关文章

  1. Delphi容器类之---TList、TStringList、TObjectList,以及一个例程的代码分析

    转载自:http://blog.csdn.net/jqandjq/article/details/5429137 看了这里标题,大家可能以为我会谈TListBox控件,那就错了.我要谈的是Delphi ...

  2. Python3 中bytes数据类型深入理解(ASCII码对照表)

    bytes的来源 bytes 是 Python 3.x 新增的类型,在 Python 2.x 中是不存在的. bytes 的意思是"字节",以字节为单位存储数据.而一个字节二进制为 ...

  3. Python-基础数据类型

    数据类型 计算机顾名思义就是可以做数学计算的机器,因此,计算机程序理所当然地可以处理各种数值.但是,计算机能处理的远不止数值,还可以处理文本.图形.音频.视频.网页等各种各样的数据,不同的数据,需要定 ...

  4. python字符串及其方法详解

    首先来一段字符串的基本操作 str1="my little pony" str2="friendship is magic" str3=str1+", ...

  5. Python3.x中bytes类型和str类型深入分析

    Python 3最重要的新特性之一是对字符串和二进制数据流做了明确的区分.文本总是Unicode,由str类型表示,二进制数据则由bytes类型表示.Python 3不会以任意隐式的方式混用str和b ...

  6. Delphi For Android 开发笔记 2 NEXTGEN下的字符串类型

    delphi开发速度迅捷至少有30%(猜的,呵呵)的原因是因为其字符串(string.WideString.PChar.PAnsiChar等)处理能力. 而从delphi XE4开始,在system等 ...

  7. delphi常用函数过程

    数据类型转化 1.1.         数值和字符串转化 Procedure Str(X [: Width [ : Decimals ]]; var S); 将数值X按照一定格式转化成字符串S.Wid ...

  8. python中unicode、utf8、gbk等编码问题

    转自:http://luchanghong.com/python/2012/07/06/python-encoding-with-unicode-and-gbk-and-utf8.html 概要:编码 ...

  9. strings

    3.1.1.1 计算列表中的字符串数目 使用Count属性可计算列表中的字符串数目.Count是只读属性,用以指示列表中字符串列表数目.因为字符串列表是以零开始索引,因而Count比列表的最大索引数大 ...

随机推荐

  1. encode decode enumerate

    format的用法 print(format('aa','>20')) print(format('aa','<20')) print(format('aa','^20')) 打印结果如下 ...

  2. 关于 Vue 方法前面的美元符号

    关于 Vue 方法前面的美元符号 学到这一段,不明白什么意思,然后手贱把 $ 删除了,出现未定义方法. vm.$watch('counter', function(nval, oval) { aler ...

  3. 特殊字符搜索网站 http://symbolhound.com/

    最近在学习makefile,想搜索一下 $@是啥意思,结果google由于忽略了特殊字符,结果啥也没找到, 后来在stackoverflow上看到了别人同样的问题 http://stackoverfl ...

  4. Array、ArrayList 区别

    ArrayList可以算是Array的加强版,(对array有所取舍的加强). 存储内容比较(可包含元素的类型不同.数组要求存储同种类型): Array数组可以包含基本类型和对象类型, ArrayLi ...

  5. 线性模型的fit,predict

    线性模型的fit其实一个进行学习的过程,根据数据和标签进行学习:predict则是基于fit之后形成的模型,来决定指定的数据对应于标签(y_train_5)的值. 下面的是手写字母判断是否为“5” s ...

  6. 转 Fiddler导出jmeter脚本

    前提条件:                1.下载安装抓包工具Fiddler                2.下载Fiddler插件,参考下载地址:http://download.csdn.net/ ...

  7. react-router4.0的使用

    近来很忙,学了一波react,特来记一笔,分享下react-router的使用方式 第一步引入内部组件 import {Route,BrowserRouter as Router,Switch,Lin ...

  8. TS流的解析

    个字节不一定都是有效数据,有一些可能为填充数据). 工作形式: 因为在TS流里可以填入很多种东西,所以有必要有一种机制来确定怎么来标识这些数据.制定TS流标准的机构就规定了一些数据结构来定义.比如: ...

  9. 用三个线程按顺序循环打印ABC三个字母

    有两种方法:semaphore信号量和mutex互斥锁.需要注意的是C++11已经没有semaphore. C++ 并发编程(六):信号量(Semaphore) - 止于至善 - SegmentFau ...

  10. [转]Windows 注册自定义的协议

    [转自] http://blog.sina.com.cn/s/blog_86e4a51c01010nik.html 1.注册应用程序来处理自定义协议 你必须添加一个新的key以及相关的value到HK ...