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. gtx860M,cuda9路1080p多高斯运动检测测试

    多高斯背景差分,非常吃cpu,特别是多路视屏,所以想用gpu做检测 后面的跟踪一系列的规则判断用cpu opencv+cuda+stl做了个测试 代码: // MTTestCudaMog.cpp : ...

  2. 剑指offer-特定二维数组中查找一个元素是否存在-二分搜索-二维数组

    int [][] array ={ {1,2,8,9}, {2,4,9,12}, {4,7,10,13}, {6,8,11,19} }; 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都 ...

  3. CentOS升级Python2.6到Python2.7并安装pip

    原文:http://ruter.sundaystart.net/2015/12/03/Update-python/ 貌似CentOS 6.X系统默认安装的Python都是2.6版本的?平时使用以及很多 ...

  4. PostgREST docker-compose 试用

    PostgREST 是一款很不错的直接将pg 数据库暴露为restapi ,使用了基于行级别安全访问控制, 比较全的restapi 查询以及集成了swagger openapi docker-comp ...

  5. goss docker-compose 集成使用

    原理很简单,就是使用volume 进行数据共享, 并执行服务器状态校验 docker-compose 文件 version: "3" services: goss: image: ...

  6. POSIX 线程具体解释(3-相互排斥量:"固定加锁层次"/“试加锁-回退”)

    有时一个相互排斥量是不够的: 比方: 当多个线程同一时候訪问一个队列结构时,你须要2个相互排斥量,一个用来保护队列头,一个用来保护队列元素内的数据. 当为多线程建立一个树结构时.你可能须要为每一个节点 ...

  7. Servlet 串联过滤器

    1. 串联Servlet过滤器的工作流程 2. 创建两个过滤器 MyFilter1和MyFilter2 1) MyFilter1 package com.example.filter; import ...

  8. RPC终结点映射

    “没有更多的终结点可用”错误消息表示 RPC 终结点映射程序无法对基于 RPC 运行的服务使用大于 1024 的端口.注意:RPC 终结点映射程序在端口 135 上运行. http://support ...

  9. wxWidgets:简单消息处理

    早期的wxWidgets使用类似MFC的方式进行消息处理:在新版中这种映射方式仍然得以保留. 在MyFrame.h中添加: private: void OnQuitButton(wxCommandEv ...

  10. 【转】深入理解java异常处理机制

    深入理解java异常处理机制 ; int c; for (int i = 2; i >= -2; i--) { c = b / i; System.out.println("i=&qu ...