I have a Russian word близко (close) and I want to check that the word is indeed in Cyrillic script
Now I know that the Unicode range for Cyrillic is 0400 to 04FF and the Cyrillic supplementary is from 0500 to 052F
In windows I have added Russian as a language pack, and in Access changed the editor format to Arial (Cyrillic)
I can copy the Cyrillic word into my table OK.
If I try to pass the word so a function to try to attempt some verification, the word appears as ??????. and obviously I can do nothing with it.
Any ideas how to pass words in non Latin languages
Thanks
Phil
Hmm, interesting. You have to use StrConv to convert it to Unicode first. - Sub Test()
-
Dim str As String, i As Integer
-
str = StrConv(DLookup("Field1", "Table2"), vbUnicode)
-
For i = 1 To Len(str) Step 2
-
Debug.Print Right("0" & Hex(Asc(Mid(str, i + 1, 1))), 2) & Right("0" & Hex(Asc(Mid(str, i, 1))), 2)
-
Next
-
End Sub
Which prints this when run against the string you supplied above. - 0431
-
043B
-
0438
-
0437
-
043A
-
043E
6 4542
Hmm, interesting. You have to use StrConv to convert it to Unicode first. - Sub Test()
-
Dim str As String, i As Integer
-
str = StrConv(DLookup("Field1", "Table2"), vbUnicode)
-
For i = 1 To Len(str) Step 2
-
Debug.Print Right("0" & Hex(Asc(Mid(str, i + 1, 1))), 2) & Right("0" & Hex(Asc(Mid(str, i, 1))), 2)
-
Next
-
End Sub
Which prints this when run against the string you supplied above. - 0431
-
043B
-
0438
-
0437
-
043A
-
043E
Thank a lot Rabbit, we're there!
Slight change of code, but I am passing this back in case you're interested
I have a table of languages that holds the Unicode language range which I pass to the function: -
Function CheckLanguageOK(Word As String, LanguageLegalFrom As Long, LanguageLegalTo As Long) As Boolean
-
-
Dim UnicodeChar As String
-
Dim UnicodeValue As Long
-
Dim i As Integer
-
Dim TestWord As String
-
-
If LanguageLegalFrom = 0 Or LanguageLegalTo = 0 Then ' Language not foun
-
Exit Function
-
End If
-
-
TestWord = StrConv(Word, vbUnicode)
-
CheckLanguageOK = -1
-
-
For i = 1 To Len(TestWord) Step 2
-
UnicodeChar = Right("0" & Hex(Asc(Mid(TestWord, i + 1, 1))), 2) & Right("0" & Hex(Asc(Mid(TestWord, i, 1))), 2)
-
UnicodeValue = Val(UnicodeChar)
-
-
If ChangeHexToDecimal("&h" & UnicodeChar) < Val(LanguageLegalFrom) Or ChangeHexToDecimal("&h" & UnicodeChar) > Val(LanguageLegalTo) Then
-
CheckLanguageOK = 0
-
Exit For
-
End If
-
Next i
-
-
End Function
-
Works perfectly
Thanks again
Sorry, a supplementary question.
I have the following series of bytes, those beginning with 04 are Cyrillic, and those beginning with 00 are English. -
0435
-
0020
-
0434
-
0430
-
043D
-
043D
-
044B
-
0435
-
003C
-
002F
-
0073
-
0070
-
0061
-
006E
-
At some point I need to strip the English stuff off and just leave the Cyrillic.
How do I convert those numbers to Unicode so that they can be read as a word?
Again thanks
Phil
Not to worry. Problem solved
Phil
Cool, just curious, what did you have to do to get it back into the table?
Hi Rabbit
The guts of the solution is below
The first bit of code is abbreviated but essentially it is translating an Input string to an Output String using say German as the input language an French as the output language
The translation line would look like this -
IE.Navigate "http://translate.google.com/#" & "de" & "/" & "fr" & "/" & "Cat"
-
Here is part of the code -
Translate2_Start:
-
Set IE = CreateObject("InternetExplorer.Application")
-
IE.Visible = 0
-
-
' TO CHOOSE INPUT LANGUAGE
-
If Nz(InLanguage) = "" Then
-
InLanguage = "auto"
-
End If
-
-
'Open website
-
IE.Navigate "http://translate.google.com/#" & InLanguage & "/" & OutLanguage & "/" & InputStr
-
-
DoEvents
-
-
Do Until IE.ReadyState = 4
-
apWait LanguageTranslateTime, 0 ' Wait half .05 seconds
-
DoEvents
-
Loop
-
-
OutputStr = Replace(IE.Document.getElementById("result_box").innerHTML, "<span>", "") ' Get rid of the HTML "<span>"
-
-
IE.Quit
-
-
If OutputStr > "" Then
-
OutputStr = Replace(OutputStr, "</span>", "") ' Get rid of the HTML "</span>"
-
OutputStr = Replace(OutputStr, "&", "&") ' Replace undescored shortcut letters
-
-
TranslatedWord = StrConv(OutputStr, vbUnicode)
-
TestWord = ""
-
For i = 1 To Len(TranslatedWord) Step 2
-
Debug.Print Right("0" & Hex(Asc(Mid(TranslatedWord, i + 1, 1))), 2) & Right("0" & Hex(Asc(Mid(TranslatedWord, i, 1))), 2)
-
TestWord = Right("0" & Hex(Asc(Mid(TranslatedWord, i + 1, 1))), 2) & Right("0" & Hex(Asc(Mid(TranslatedWord, i, 1))), 2)
-
TmpWord = TmpWord & CharW("U" & TestWord, -1) ' Indicate it's a unicoode character
-
Next i
-
-
Debug.Print StrConv(OutputStr, vbUnicode)
-
End If
-
The second function uses the ChrW$ function to return each 4 digit hex number as a Cyrillic letter (providing you have the Russian Language pack installed?????)
I add the ???? because I can translate into Mongolian (well someone has to) and I don't have the Mongolian language pack installed.
In fact I have just added Bengali as a language, to translate to, but have not added the language pack, and it is coming out OK.
Interesting! -
Public Function CharW(TestWord As Variant, Optional Exact_functionality As Boolean = False) As String
-
' Use a Leading “U” or “u” to indicate Unicode values
-
' Exact_functionality returns the Unicode characters for Ascii(128) to Ascii(159) rather than the Windows characters
-
-
If UCase(Left$(TestWord, 1)) = "U" Then
-
TestWord = Replace(TestWord, "U", "&H", 1, 1, vbTextCompare)
-
End If
-
-
TestWord = CLng(TestWord)
-
-
If TestWord < 256 Then
-
If Exact_functionality Then
-
CharW = ChrW(TestWord)
-
Else
-
CharW = Chr(TestWord)
-
End If
-
Else
-
CharW = ChrW(TestWord)
-
End If
-
-
End Function
-
Phil
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Suddn |
last post by:
Help me get my mind around passing string types to a function.
I need to have the function modify the string types and get them back.
Normaly I would just return the modified string but I need to...
|
by: o1j2m3 |
last post by:
I created 2 forms, A and B using VB.NET 2003
in A, the codes are :
==========================
public AsName as string
public AsPrice as double
public sub setValue(ByVal sname as string,...
|
by: muntyanu |
last post by:
Hi all,
I am passing string from C++ to C# but not sure which way is more
correct. Here it is:
First approach:
CDAnetCSharpHooks::PassString( )
{
char str = "String to pass";
DotNetObject...
|
by: Pontifex |
last post by:
Hi all,
Has anyone devised a simple method for passing
a string to an external script?
For instance, suppose I want to produce a title bar
that is very fancy and I don't want my main HTML...
|
by: goldtech |
last post by:
Hi,
I'm passing what I think is a string parameter to another Python
program (spawn.py) - see the code snip below. But only the counter
part gets printed to a log file via spawn.py. Yet the...
|
by: pcaisse |
last post by:
Could someone please tell me why this stupid script doesn't print the string being passed to the sub?:
#!/usr/bin/perl -w
use strict;
print "Work, damnit!\n";
my $val = "print me";
|
by: Kerem Gümrükcü |
last post by:
Hi,
i want to emulate a (synchronous) BroadCastSystemMessage
with EnumWindows and SendMessage. I dont want to use
the BroadcastSystemMessage because it needs the SE_TCB_NAME
Privilege (you...
|
by: Peeyush81 |
last post by:
Hi,
I have created a win32 dll with an exported method.
extern "C" __declspec(dllexport) void LocateAddress(struct stLocateAddressParam arrAddressParam,int nClientType, LPTSTR outptr);
In...
|
by: BobbyS |
last post by:
I've a xml file.I'm taking its data passing it to a method in string form and converting that string "xmlData" to a array of bytes by Convert.FromBase64String(xmlData) but I'm getting a exception...
|
by: masso600 |
last post by:
char word;
in = fopen("test.txt", "r");
while(fscanf(in,"%s",&word)!=EOF)
{
/* Print all words */
/* printf("%s\n",&word); */
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |