PDA

View Full Version : سوال: کد اسکی حروف و اعداد فارسی



hrsaberi
سه شنبه 22 تیر 1389, 14:28 عصر
سلام
اگر كسي اكسي كدهاي فارسي رو به صورت كامل داره لطفا در اينجا قرار بده.

****** شامل اعداد و حروف *****

pezhvakco
سه شنبه 22 تیر 1389, 18:18 عصر
درود :
دو تا Edit رو فرم بزار و داخل روبداد OnKeyDown یکی از اون ها کد دستور زیر رو بنویس >

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Edit2.Text:=IntToStr(Key);
end;

فکر خوش .

hrsaberi
سه شنبه 22 تیر 1389, 19:21 عصر
تشكر
ولي منظور از سوال: شناسايي متني كه شامل كاراكتر يونيكد باشد.

tdkhakpur
سه شنبه 22 تیر 1389, 19:47 عصر
ولي منظور از سوال: شناسايي متني كه شامل كاراكتر يونيكد باشد.

بستگی به کد پیج دارد که از کدام نقطه شروع شده باشد مثلا اگر نقطه شروع 14000 باشد حرف 'a' به شکل زیر هست


14000+ord('a') = key;

hrsaberi
سه شنبه 22 تیر 1389, 19:52 عصر
يك كنترل Memo در فرم داريم.
مي خواهيم اگر كاربر اولين كاراكتر را فارسي تايپ كرد تشخيص بديم.
فقط همين.

tdkhakpur
سه شنبه 22 تیر 1389, 22:17 عصر
خب اگر memo از unicode پشتیبانی کرده باشد شما باید متن را برای دریافت unicode جستجو کنید اگر پشتیبانی نکرده باشد کدهای یکسان برای هر دو نوع (فارسی و لاتین)که زیر 255 هست را نمایش خواهد داد.
ولی در کل اگر از api بخواهید استفاده کنید میتوانید


The ToUnicode function translates the specified virtual-key code and keyboard state to the corresponding Unicode character or characters.
int ToUnicode(
UINT wVirtKey, // virtual-key code
UINT wScanCode, // scan code
PBYTE lpKeyState, // address of key-state array
LPWSTR pwszBuff, // buffer for translated key
int cchBuff, // size of translated key buffer
UINT wFlags // set of function-conditioning flags
);

Parameters
wVirtKey
Specifies the virtual-key code to be translated.
wScanCode
Specifies the hardware scan code of the key to be translated. The high-order bit of this value is set if the key is up.
lpKeyState
Points to a 256-byte array that contains the current keyboard state. Each element (byte) in the array contains the state of one key. If the high-order bit of a byte is set, the key is down.
pwszBuff
Points to the buffer that receives the translated Unicode character or characters.
cchBuff
Specifies the size in characters of the buffer pointed to by the pwszBuff parameter.
wFlags
A set of bit flags that condition the behavior of the function. Set bit 0 if a menu is active. Bits 1 through 31 are reserved.

Return Values
The function returns one of the following values:
Value Meaning
- 1 The specified virtual key is a dead-key character (accent or diacritic). This value is returned regardless of the keyboard layout, even if several characters have been typed and are stored in the keyboard state. If possible, even with Unicode keyboard layouts, the function has written a spacing version of the dead-key character to the buffer specified by pwszBuffer. For example, the function writes the character SPACING ACUTE (0x00B4), rather than the character NON_SPACING ACUTE (0x0301).
0 The specified virtual key has no translation for the current state of the keyboard. Nothing was written to the buffer specified by pwszBuffer.
1 One character was written to the buffer specified by pwszBuffer.
2 or more Two or more characters were written to the buffer specified by pwszBuff. The most common cause for this is that a dead-key character (accent or diacritic) stored in the keyboard layout could not be combined with the specified virtual key to form a single character.

Remarks
The parameters supplied to the ToUnicode function might not be sufficient to translate the virtual-key code because a previous dead key is stored in the keyboard layout.
Typically, ToUnicode performs the translation based on the virtual-key code. In some cases, however, bit 15 of the wScanCode parameter can be used to distinguish between a key press and a key release.
See Also

مطالعه کنید(راهنمای خود دلفی)