When I use function Chr(225), I get character "á", because code page of Windows is 1250 (System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage)
Is it possible to use Chr(225), but get character of another code page?
For example code 225 represents in code page DOS-852 character "ß".
I need to convert "á" to "ß".
Is it possible to get character of DOS code page 852?
For example Chr(225) should return "ß".
Thanks!
You can get an Encoding for a specific code page, 852 in your case:
Dim enc = Text.Encoding.GetEncoding(852)
Dim str = enc.GetString(New Byte() {225})
Have a look at the Encoding class in general for conversions between text encodings.
Related
Im trying to obtain the Unicode(code) of a character in VTL.
For example I would like to get the number 902 from the character Ά
The analogue in JS would be:
'Ά'.charCodeAt(0)
902
Similarly the char code of a blank space would be 32:
' '.charCodeAt(0)
32
What you need is the Character.codePointAt(str, index) static method.
#macro(unicode, $chr)
#set($str = "$chr")
$str.charAt(0).codePointAt($str, 0)
#end
#unicode('Ά')
Explanation: in VTL we need (dummy) instances to call static methods. We first convert the argument to a string and call charAt(0) on it to get a Character instance, just to be able to call the codePointAt() static method on its first character.
This seems rather convoluted, alas the Java API is not so great here.
I'm using VB.NET to consume Sabre Web Services, primarily using SabreCommandLLSRQ to send native Sabre commands. Sending special characters without any special encoding works fine, but when I try to manipulate any response that contain the Cross of Lorraine using the Response element of SabreCommandLLSRS all of the Cross of Lorraine chars are missing if I display my string in a MsgBox or try to manipulate it.
If I push that string into my clipboard and view it in Notepad++, the characters are there but they seem to be encoded improperly - they come through as something like "‡". I'm pretty new to unicode encoding so that's all a bit above my head.
I've tried using the Replace method of String Builder to change those characters to something visible no avail - anyone have a way around this issue?
Strangely, the other special characters (e.g. "¤") seem to come through just fine.
This section in Dev Studio includes references to special character hex codes:
https://developer.sabre.com/docs/read/soap_apis/management/utility/Send_Sabre_Command
Does this help?
This is a pain in the behind due to the invisible characters.
String replace does work you just need to make sure you capture the invisible character after the Â
Simply in the SabreCommandSend function before you send the string to Sabre put something like the below.
Hopefully this should copy and paste straight out including the invisible character.
if (tempCommand.Contains("‡"))
{
tempCommand = tempCommand.Replace("‡", "Â");
}
I figured out how to get this to work, but its not pretty so if anyone has a better way to do it, I'm all ears.
I couldn't figure out what char to use to do the simple string Replace method, so instead I'm casting the string to a byte array, iterating through the array and replacing any strange characters I find, recasting the byte array into a raw string and doing the string replace on that:
Imports System.Text
Dim byteArray() As Byte = System.Text.Encoding.ASCII.GetBytes(sabreResponse)
For i = 0 To byteArray.Length - 1
If byteArray(i) = 63 Then 'this is a question mark char
byteArray(i) = 94 'caret that doesn't exist in native Sabre
End If
Next
MyClass.respString = System.Text.ASCIIEncoding.ASCII.GetString(byteArray)
MyClass.respString = MyClass.respString.Replace("^", "¥")
For whatever reason, the string replace method works after I swap out the offending byte with a dummy character but not before.
I am trying to return the 2 byte WORD Hex value of a string character which is not typically English. Basically the Unicode representation. Using vb.net
Ex:
FF5F = ((
FF06 = &
These are represented in unicode standard 6.2. I do not have the ability to display some of the foreign language characters displayed in this set.
So would like for my string character to be converted to this 2 byte value. I haven't been able to find a function in .net to do this.
The code is currently nothing more than a for loop cycling through the string characters, so no sample progress.
I have tried the AscW and ChrW functions but they do not return the 2byte value. ASCII does not seem to be reliable above 255.
If necessary I could isolate the possible languages being tested so that only one language is considered through the comparisons, although an English character is always possible.
Any guidance would be appreciated.
I think you could convert your string to a byte array, which, would look something like this in C#:
static byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
From that you can just grab to two first bytes from the array, and there you go, you have them.
If you want to show them on a screen, I guess you should probably convert them to hex or some such displayable format.
I've stolen this from the question here.
A collegaue assisted in developing a solution. Each character of the string is converted to character array, and then to an unsigned integer, which is then converted to Hex.
lt = myString
Dim sChars() As Char = lt.ToCharArray
For Each c As Char In sChars
Dim intVal As UInteger = AscW(c)
Debug.Print(c & "=" & Hex(intVal))
Next
Note the AscW function... AscW returns the Unicode code point for the input character. This can be 0 through 65535. The returned value is independent of the culture and code page settings for the current thread. http://msdn.microsoft.com/en-us/library/zew1e4wc(v=vs.90).aspx
I then compare the resulting Hex to the spec for reporting.
I need to generate an URL string for a SSRS report (in order to link it with our CRM software). The report name is in Hebrew. When I send the URL string (with Heb) to Internet Explorer, it doesn't recognize the address because it isn't encoded with Percent-encoding (BTW, it works fine in Firefox). (Sending a URL with English only does work fine that way.)
Anyway, I tried to perform the encoding. I succeeded converting it to URI with UNICODE characters. I need to get the URI in UTF-8. For example, the letter 'י' should be converted into '%d7%99' and not to '%05%D9'.
I included a link:
A table with the codes, for your use, if needed.
I need the conversion\encoding function for 1 character. I can build the rest of the script / function for the complete string by myself.
I used a script which used the master.sys.fn_varbintohexstr function. As I said, though, the results aren't proper for IE.
the following:
SELECT master.sys.fn_varbintohexstr((CAST (N'י' AS varbinary)))
will get 0xd905, which I formatted into percent encoding. I should get 'd7 99' instead.
wrap up:
I convert an Hebrew character into URI percent encoding. I get a unicode result. I wish > to get a utf8 result.
Input = 'י'. Current output = %d9. Wanted output = %d7%99
How can I get those results?
I have had to deal with a few similar problems and there are two approaches that you may wish to consider; the first is to transform your data into HTML in the query and then render the result as HTML in the RDL, the second is to use JQuery to identify those cells with the incorrect value on the client and then transform that cell (again, using JQuery). The benefit of the second option is that if the server rendering is working on Firefox the transformation overhead doesn't get invoked. The downside is that if you are not rendering the report as HTML it won't work.
For the first option, in the select statement you would need to alter the appropriate column to produce a nvarchar value that looks like
<span style="font=yourfont;" charset="UTF-8">linkname</span>
With that string as data you then assign that to the appropriate columns (or cells, as needed)
In the RDL designer drag a placeholder for your field onto the designer and right click the placeholder and select placeholder properties then you can select to display the content as HTML.
I copied code to map a network drive from http://www.vbforums.com/showthread.php?t=616519 to map the drive and http://cjwdev.wordpress.com/2010/05/30/delete-network-drive/ to delete the drive. I want to know what "R"c means in this code:
RemoveNetworkDrive("R"c, True)
which came from the first link and then I want to know how to simulate this notation in a variable so I can check for the first available drive and map the network drive to that letter. I would Google search it but since I don't know what "R"c means it makes it difficult.
"R"c is the Char version of "R". You use it when you want to specify a character rather than a string.
MSDN has some details here:
You can also create an array of strings from a single string by using the String.Split Method. The following example demonstrates the reverse of the previous example: it takes a shopping list and turns it into an array of shopping items. The separator in this case is an instance of the Char data type; thus it is appended with the literal type character c.
Dim shoppingList As String = "Milk,Eggs,Bread"
Dim shoppingItem(2) As String
shoppingItem = shoppingList.Split(","c)
It converts your string "R" to a char, as requested from function
Public Shared Sub RemoveNetworkDrive(ByVal DriveLetter As Char, ...)
It's the syntax for a character literal, basically - it's the equivalent of 'R' in C#, if that makes it any clearer.