Sending and Displaying Hex Values on a Web Page using CICS COBOL - cobol

I want to send a hexadecimal value to the web page via CICSWEB (COBOL).
For example I MOVE 'DACA' to OT-S (OT-S is the variable), when I send this variable to web page , The characters 'DACA' are shown instead of showing the equivalent hexadecimal value.
My code is:
*************************
MOVE OT-S TO NAMEVAL.
EXEC CICS DOCUMENT CREATE
DOCTOKEN(TOKEN1)
TEMPLATE(WBTMP1)
SYMBOLLIST(SYMLIST1)
LENGTH(LENGTH OF SYMLIST1)
DELIMITER(DL1)
END-EXEC.
EXEC CICS WEB SEND DOCTOKEN(TOKEN1)
CLNTCODEPAGE('8859-1')
END-EXEC.
In the above code NAMVAL is a variable that must send to symbol in web page.
I expect the equivalent value of hexadecimal (which is a Persian word) to be displayed when this variable is sent to the page, but the same initial value is displayed.

You can move hexadecimal literals in COBOL by using the notation x'DACA' or x"DACA". I understand this is what you have asked, but as #Hogstrom and #GilbertLeBlanc noted you may need to manipulate code pages to get your desired result.
IBM Enterprise COBOL also supports national literals and DBCS literals, and CICS supports specific code pages in documents via the HOSTCODEPAGE option on DOCUMENT CREATE.

Related

Update variable information in the openwrt web interface luci

From the picture we see the value of RSSI, there is a code on lua and sh that displays this value, the script sh writes a value to the file, in lua we write it to a variable from the file and assign it to the label element
os.execute('/bin/rssi')
file = io.open("/tmp/rssi", "r");
d:option(DummyValue, "label", "rssi: "..(file:read("*line")));
file:close();
Everything works, but I want to see information in the web interface every N second. I will be grateful for your help.
It's something that has to be implemented at the frontend (HTML, JS, PHP), not in the Lua backend. I don't know how the kids do it these days, but from what I know, you'd need to use JavaScript to refresh that part of the HTML document every few seconds, as you want.
The way it works is as such:
Request a web page from Chrome/Firefox/Opera/Edge;
Web server opens requested file, if file is a script, script runs;
Script retrieves data from systems, databases, etc.;
3.1 Lua script runs, returns value (of RSSI, for you);
3.2 Script replaces variable by value returned by Lua script;
3.3 Script returns HTML code where variables have been replaced by values from databases, systems, etc.;
Web server sends data over the network;
Client web browser displays the data, usually as a HTML document formatted by CSS, with JavaScript interactivity, and automatic activities.
In your case, you'd want this:
JavaScript in client browser refreshes part of the document, essentially going through steps 1-5, but only replacing a portion of what's being displayed (an HTML element).

lua reading chinese character

I have the following xml that I would like to read:
chinese xml - https://news.google.com/news/popular?ned=cn&topic=po&output=rss
korean xml - http://www.voanews.com/templates/Articles.rss?sectionPath=/korean/news
Currently, I try to use a luaxml to parse in the xml which contain the chinese character. However, when I print out using the console, the result is that the chinese character cannot be printed correctly and show as a garbage character.
I would like to ask if there is anyway to parse a chinese or korean character into lua table?
I don't think Lua is the issue here. The raw data the remote site sends is encoded using UTF-8, and Lua does no special interpretation of that—which means it should be preserved perfectly if you just (1) read from the remote site, and (2) save the read data to a file. The data in the file will contain CJK characters encoded in UTF-8, just like the remote site sent back.
If you're getting funny results like you mention, the fault probably lies either with the library you're using to read from the remote site, or perhaps simply with the way your console displays the results when you output to it.
I managed to convert the "中美" into chinese character.
I would need to do one additional step which has to convert all the the series of string by using this method from this link, http://forum.luahub.com/index.php?topic=3617.msg8595#msg8595 before saving into xml format.
string.gsub(l,"&#([0-9]+);", function(c) return string.char(tonumber(c)) end)
I would like to ask for LuaXML, I have come across this method xml.registerCode(decoded,encoded)
Under that method, it says that
registers a custom code for the conversion between non-standard characters and XML character entities
What do they mean by non-standard characters and how do I use it?

Rails: Plus sign in GET-Request replaced by space

In Rails 3 (Ruby 1.9.2) I send an request
Started GET "/controller/action?path=/41_+"
But the parameter list looks like this:
{"path"=>"/41_ ",
"controller"=>"controller",
"action"=>"action"}
Whats going wrong here? The -, * or . sign works fine, its just the +which will be replaced by a space.
That's normal URL encoding, the plus sign is a shorthand for a space:
Within the query string, the plus sign is reserved as shorthand notation for a space. Therefore, real plus signs must be encoded. This method was used to make query URIs easier to pass in systems which did not allow spaces.
And from the HTML5 standard:
The character is a U+0020 SPACE character
Replace the character with a single U+002B PLUS SIGN character (+).
For POST-requests, (in case that's how some of you stumbled upon this question, like me) one might encounter this problem because one has encoded the data in the wrong way on the client side. Encoding the data as application/x-www-form-urlencoded will tell rails to decode the data as it decodes a URL, and hence replace + signs with whitespace, according to the standard RFC1738 as explained by #mu is too short
The solution is to encode the data on the client side as multipart/form-data.
In PHP, using cURL, this is done by taking into consideration the following gotcha:
Passing an array to CURLOPT_POSTFIELDS will encode the data as
multipart/form-data, while passing a URL-encoded string will encode
the data as application/x-www-form-urlencoded. http://php.net/manual/en/function.curl-setopt.php
You might wonder why I was using PHP on the client side (that's because the client in my example was another webserver, since I'm working on an API connection.)

TJvHidDeviceController "DevicePath" always showing "\"

I'm using TJvHidDeviceController class to retrive HID Device information. I have plugged two HID devices, but i'm trying to ge the "DevicePath" of SP_DEVICE_INTERFACE_DETAIL_DATA_A structure always getting the device path as '\'. So Ican't open CreateFile function. Please help me to solve this issue. My OS win7.
Thanks All.
This is guessing!
The one thing I can think of is:
TJvHidDeviceController calls a Windows API call WITHOUT using an A or W suffix. The structure used is SP_DEVICE_INTERFACE_DETAIL_DATA_A, the ANSI version. Now, if you use Delphi 2009 or higher, the routine will expect SP_DEVICE_INTERFACE_DETAIL_DATA_W. size is the same so everything looks OK. But the strings stored will be USC2 encoded (WideChars) instead of ANSI encoded -> thus after every ANSI character there will be a null byte. TJvHidDeviceController probably converts the character array back to a pascal string using a function like StrPas and hence, you only see the first character.
Check:
Set a breakpoint just after the function call that fills the structure and use the CPU window to view the content as a memory dump. If you see ANSI characters every other byte and null bytes in between, you can confirm that the above scenario is the case.
Solution:
Check if the call is using the wide variant and change the structure accordingly.
Check if the call is using the wide variant and use the A variant instead. This is probably the easiest option.

Translate binary characters to a human readable string?

So let's say we have a string that is like this:
‰û]M§Äq¸ºþe Ø·¦ŸßÛµÖ˜eÆÈym™ÎB+KºªXv©+Å+óS—¶ê'å‚4ŒBFJF󒉚Ү}Fó†ŽxöÒ&‹¢ T†^¤( OêIº ò|<)ð
How do I turn it into a human readable string of chars, cuz like it was a wierd output of HTML from a webserver that is text I think cuz half the web page loaded correctly. Do I need to read it with like C or Python or something. That's only a snippet of the string.
If that is in fact supposed to be a human-readable string, you'll need to figure out what character encoding it uses and translate. It's also possible that the string is compressed, encrypted, or represents binary data. It would be helpful to know where you got your string from.
I'm guessing your web server isn't sending the correct mime-type. I'd suggest taking a look at the http headers using Firefox's Live Headers plugin. If a web server decides to send you a pdf, but doesn't set the mime-type, you'll just see garbage on your screen. Alternatively, save the page to a file, and then run these commands from Cygwin or a unix shell:
file mypage.htm
strings mypage.htm
The first will tell you if the header bytes follow any recognizable pattern. The second will strip out and display all the human readable text.

Resources