转载自:http://qing.blog.sina.com.cn/1820422183/6c81702733001qvk.html 1.c版 int hexcharToInt(char c) { if (c >= '0' && c <= '9') return (c - '0'); if (c >= 'A' && c <= 'F') return (c - 'A' + 10); if (c >=…
using namespace std; #include <iostream> #include<string> //第1种,用string自带的s.subdtr()截取任意子串,再用s.compare()确定是否与待求子串相等,时间复杂度O(len1*len2) int index1(string s,string t) { int i = 1; int len1 = s.length(); //主串长度 int len2 = t.length(); //子串长度 string…
procedure Hex2Png(str: string; out png: TPngObject); var stream: TMemoryStream; begin if not Assigned(png) then png := TPngObject.Create; stream := TMemoryStream.Create; stream.SetSize(Length(str) ); HexToBin(PChar(str), stream.Memory, stream.Size);…
import org.apache.commons.lang.ArrayUtils; import java.nio.charset.Charset; /** * 字节数组转换工具类 */ public class BytesUtils { public static final String GBK = "GBK"; public static final String UTF8 = "utf-8"; public static final char[] asci…
PChar,PAnsiChar,String,AnsiString,Char数组,AnsiChar数组之间的转换关系见下图 通过转换链,可以实现任意两个类型之间的互转.如PChar转PAnsiChar,根据转换链可知 Dest := PAnsiChar(AnsiString(Source)),同理PAnsiChar转PChar为 Dest:= PChar(String(Source)) 如果转换结果最终为string,可以无需String转换,如Array[0..n] of AnsiChar转s…