I want to read a String/character from Click PLC in C# and I don't know how to read the register. who know how to read the register
I want to read de character or the decimal value to convert to a ASCII character
Related
in the Net level emoji code is directly converted to the black and White emoji
example
when .Net Received
:punch: converted to converted to 👊
:+1:converted to converted to 👍
:-1:converted to converted to 👎
and these are on convert on system level we received directly black and White emoji
but some emoji not converted with the different name... and so how can I add this on the system level that these emoji also convert with the different name.. because some platform sends :+1: and some send :thumbsup: ?
these emoji not converted
:facepunch: Not converted to converted to 👊
:thumbsup: Not converted to converted to 👍
:thumbsdown:converted to converted to 👎
These are the same emoji with different name and all these emoji converted on another platform like android,ios
in the Net level emoji code is directly converted to the black and White emoji
there's no such thing as the "Net level". You deal with strings that contain unicode codepoints; how these are rendered is a totally different affair.
You're not mentioning what software does this, but I assure you that .Net doesn't take your string containing :emoji: and convert it to a single unicode codepoint. That's the job of whatever you use to enter these strings, or it is the job of whatever takes these strings and renders them.
At any rate, it's not a bug that a text console doesn't convert :squirtgun: to a picture of a squirt gun.
So, go wild. Build your own :emoji: conversion routines. It's a moving target.
Is it possible to read a file hex values into c# and output the corresponding ASCII? I can view the file in a hex editor which I can then see the appropriate ASCII next to the hex but rather than manually copying out the parts I need I imagine there is a way of the machine doing it for me in a c# program?
I did find Converting HEX data in a file to ascii but that didn't really help?
It sounds like you just need:
string text = File.ReadAllText("file.txt");
There's no such thing as "hex values" in a file - they're just bytes which are shown as hex in various editors geared towards editing non-text files.
The above line of code will load a text file, decoding it as UTF-8 - which is compatible with ASCII, so if your file is truly ASCII, it should be fine. If you need to specify a different encoding, you can do it with an overload, e.g.
// Load an ISO-8859-1 file
string text = File.ReadAllText("file.txt", Encoding.GetEncoding(28591));
I have a legacy C++ COM application which writes a BSTR (UTF-16 on Windows) like this.
Say, ☻ (Black Smiley i.e. ALT + Numpad 2) is written like this in HEX
- 060000003B260D000A00 by the application. Note that 1st 4 bytes are reserved for BSTR length
Now, how do I display back the black smiley in C# from this HEX string ? In VS debugger, '\u263B' displays the smiley, but here the string is 3B26. This is just an example of a kind of data. Any data can be dumped by that app (like large XSLs, Texts, etc. - all converted in HEX format). Idea is to interpret the HEX correctly in C#.
This link talks something similar, but not very sure. Any pointers ?
Use Marshal.PtrToStringBSTR to get an instance of a managed String from your BSTR.
Note that the IntPtr argument should be a pointer to the start of the string characters themselves, not the start of the 4 bytes which encode the length of the string.
All,
So I'm uploading a text file from C# to an IBM MVS mainframe. The file is converted to ebcdic using C# libraries and it works well as I can read the data on the mainframe. The problem is the new lines. The text file has 10 rows of data and while viewing it in the mainframe environment, all data is present. But there are no new lines as it translates each new line from the text file as 0D25, which is CRLF. This segment appears as .. on screen.
I don't want the the 2 dots that have the hex reading of 0D25 because I need it to actually place the data on the next line as it is in the text file. The file is variable block length once on the mainframe btw. How can I achieve the same formatting as the text file while viewing the uploaded file on MVS ?
example:
TEXT FILE VIEW
12345
23456
12346
IBM MAinFrame View
12345..23456..12346
or if block length has been reached..
12345..2345
6..12346
Thanks
If you're doing the ASCII-EBCDIC translation outside of the FTP transfer process, I have to assume that you're transferring in binary mode (otherwise the translation would be done again and your data would be bad).
If that is the case, then I'm pretty certain you're responsible yourself for the conversion of line endings as well. Binary transfers will not attempt to convert line endings. You'll need to pad out the lines to the desired lengths and remove the line endings altogether, before sending it up to the host.
By way of example, if you transfer this file:
12345
67890
up in binary mode using literal site recfm=vb, you'll get the following (shown in ISPF editor with hex on):
000001
3333300333330044444
12345DA67890DA00000
--------------------------
You can see it's just transferred the bytes as-is, including the CR/LF. If you switch to ASCII mode in FTP and upload again, you get:
000001 12345
FFFFF44444444
1234500000000
--------------------
000002 67890
FFFFF44444444
6789000000000
--------------------
Here, the characters have been converted to the right EBCDIC code points and the line endings have been morphed into padding with EBCDIC spaces.
I suppose my first question to you would be: "Why are you doing the translation outside of FTP?"
IBM invests quite a lot of money in ensuring that it will accept all sorts of different encodings and translate them into the correct code page. It's very unlikely that a stand-alone solution will work on all the internationalised versions of z/OS as well as IBM's own.
If you must convert on the client and transfer in binary mode, you'll either have to have the client do the line ending conversion and padding as well or post-process the file after the transfer, such as with a REXX script.
If you don't know what the properties of the target data set will be (such as if you're transferring into a member in a PDS), the latter option may be the only viable one.
I'm implementing serial key functionality in my application. User needs to enter at least 64bit number in order to register the application. Because typing number like 9,223,372,036,854,775,807 will take a while I want to compress it a bit. The first guess was to code this number hexadecimally but it still is quite long (0x7FFF FFFF FFFF FFFF).
Is there any standard method in .NET to code this number alphanumerically using for example: digits, upper-case and lower-case characters?
Base 64 is probably what you want. It allows all the uppercase and lowercase characters, and two symbol characters (+ and /)
Convert.ToBase64String will convert a number to a string.
Convert.FromBase64String converts string back to number.
Alternatively, if you want just uppercase characters (and digits 2-7) then you could use Base32, but there isnt a native implementation for that in .net. Some further info here : Base32 Decoding
If you want to add serial key functionality in your project then during the deployment you can add serial key.That is the standard way of .NET to add key.Create new deployment project and add user interface editor in that project.Then add customer information window in it. Then in its property you can put whatever pattern you want as a aplha numeric or only numeric whatever.The detail steps of doing this I mention in my blog you can refer it from here.