📄 charutil.cpp
字号:
/* charutil.cpp * * Character set conversion utilities for PuTTY Symbian OS port * * Copyright 2002 Petteri Kangaslampi * * See license.txt for full copyright and license information.*/#include <e32std.h>#include <string.h>extern "C" {#include "putty.h"}#include "charutil.h"#ifdef _UNICODEtypedef TUint16 CharType;#elsetypedef TUint8 CharType;#endifvoid StringToDes(const char *aStr, TDes &aTarget) { // FIXME: Doesn't really work for anything except US-ASCII aTarget.SetLength(0); while ( *aStr ) { aTarget.Append(*aStr++); }}TPtr *CreateDes(const char *aStr) { int len = strlen(aStr); CharType *buf = (CharType*) smalloc(len * sizeof(CharType)); TPtr *ptr = new TPtr(buf, len); if ( !ptr ) { fatalbox("Out of memory"); } StringToDes(aStr, *ptr); return ptr;}void DeleteDes(TPtr *aDes) { const CharType *ptr = aDes->Ptr(); sfree((void*)ptr); delete aDes;}// Converts a descriptor into a C string. The string needs to be pre-allocatedvoid DesToString(const TDesC &aDes, char *aTarget) { int i = 0; int len = aDes.Length(); while ( i < len ) { *aTarget = (char) aDes[i]; aTarget++; i++; } *aTarget = 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -