I've some records which are really messed up.
My team lead told me to find out the position of characters with ascii value 14 and 15.
I've a query
SELECT CHARINDEX(CHAR(14),X_CUSTOMER_COMMENTS)
FROM vp_service_requests;
SELECT CHARINDEX(CHAR(15),X_CUSTOMER_COMMENTS)
FROM vp_service_requests;
which returns 0 because i wasn't able to find char with 14 and 15 ascii value after google
search i found 14 and 15 ascii value are for shift in and shift out
how this represents on keyboard so i can try for it with CHAR(14) function.
As a holdover from the old DOS days, Windows still allows you to enter certain old ASCII keys from the keyboard by pressing and holding the ALT key, followed by the three-digit code you wish to enter (from the 10-key pad, not the numeric row atop the keyboard), eg for 14, type ALT-014.
However, some of the lower-level codes are inherited from old terminal functions, eg ASCII 7 is a bell, 8 is a backspace, eg, and rather that typing a character, they cause the cursor to behave a certain way or induce an application to respond in a defined manner. You can embed a CHAR(XX) value for testing simply by concatenating the value into a string and INSERTing it into your test table.
It should be Ctrl-N and Ctrl-O although I doubt this will help.
Try loading the records into a good editor and look at them in HEX. Weird characters should stick out like a sore thumb
Related
So I have some code that does essentially this:
REAL, DIMENSION(31) :: month_data
INTEGER :: no_days
no_days = get_no_days()
month_data = [fill array with some values]
WRITE(1000,*) (month_data(d), d=1,no_days)
So I have an array with values for each month, in a loop I fill the array with a certain number of values based on how many days there are in that month, then write out the results into a file.
It took me quite some time to wrap my head around the whole 'write out an array in one go' aspect of WRITE, but this seems to work.
However this way, it writes out the numbers in the array like this (example for January, so 31 values):
0.00000 10.0000 20.0000 30.0000 40.0000 50.0000 60.0000
70.0000 80.0000 90.0000 100.000 110.000 120.000 130.000
140.000 150.000 160.000 170.000 180.000 190.000 200.000
210.000 220.000 230.000 240.000 250.000 260.000 270.000
280.000 290.000 300.000
So it prefixes a lot of spaces (presumably to make columns line up even when there are larger values in the array), and it wraps lines to make it not exceed a certain width (I think 128 chars? not sure).
I don't really mind the extra spaces (although they inflate my file sizes considerably, so it would be nice to fix that too...) but the breaking-up-lines screws up my other tooling. I've tried reading several Fortran manuals, but while some of the mention 'output formatting', I have yet to find one that mentions newlines or columns.
So, how do I control how arrays are written out when using the syntax above in Fortran?
(also, while we're at it, how do I control the nr of decimal digits? I know these are all integer values so I'd like to leave out any decimals all together, but I can't change the data type to INTEGER in my code because of reasons).
You probably want something similar to
WRITE(1000,'(31(F6.0,1X))') (month_data(d), d=1,no_days)
Explanation:
The use of * as the format specification is called list directed I/O: it is easy to code, but you are giving away all control over the format to the processor. In order to control the format you need to provide explicit formatting, via a label to a FORMAT statement or via a character variable.
Use the F edit descriptor for real variables in decimal form. Their syntax is Fw.d, where w is the width of the field and d is the number of decimal places, including the decimal sign. F6.0 therefore means a field of 6 characters of width with no decimal places.
Spaces can be added with the X control edit descriptor.
Repetitions of edit descriptors can be indicated with the number of repetitions before a symbol.
Groups can be created with (...), and they can be repeated if preceded by a number of repetitions.
No more items are printed beyond the last provided variable, even if the format specifies how to print more items than the ones actually provided - so you can ask for 31 repetitions even if for some months you will only print data for 30 or 28 days.
Besides,
New lines could be added with the / control edit descriptor; e.g., if you wanted to print the data with 10 values per row, you could do
WRITE(1000,'(4(10(F6.0,:,1X),/))') (month_data(d), d=1,no_days)
Note the : control edit descriptor in this second example: it indicates that, if there are no more items to print, nothing else should be printed - not even spaces corresponding to control edit descriptors such as X or /. While it could have been used in the previous example, it is more relevant here, in order to ensure that, if no_days is a multiple of 10, there isn't an empty line after the 3 rows of data.
If you want to completely remove the decimal symbol, you would need to rather print the nearest integers using the nint intrinsic and the Iw (integer) descriptor:
WRITE(1000,'(31(I6,1X))') (nint(month_data(d)), d=1,no_days)
I want to pad a format string to a certain length. For example, the Tmux Battery plugin introduces the battery_percentage format string. I can use this in the status bar as #{battery_percentage}. The battery percentage values can be:
Between 0% and 9% (One Digit).
Between 11% and 99% (Two Digits).
Exactly 100% (Three Digits).
I want the format string to always be displayed 3 digits, padded with spaces at the end, how can I achieve that?
I saw that there is the format #{pN:variable} in this page, but it did not work when I tried to use it with format strings, even though at the end they are variables. Maybe I just did not know how to use it, I don't know...
Looking at the plugin startup code, battery.tmux, you can see that ${battery_percentage} is actually converted to #($CURRENT_DIR/scripts/battery_percentage.sh), which is a request to run a script. I don't know if #{p3:#(...)} can be made to work since this is not a simple variable.
You could always edit the plugin shell script to return the padded string (assuming tmux keeps the leading spaces).
My program makes calculations on physics vectors and it allows copy/pasting from websites and then tries to parse them into the x, y, and z components automatically. I've come across one website (http://mathinsight.org/cross_product_examples) that has (3,−3,1). While that looks normal, that minus is actually not recognized by VB. Visually, it is longer than the normal minus (− and -), but return the same Unicode of 45. This picture shows the Unicode for every character (I added a minus in front of the first 3 for comparison) in the Textbox. Also, from this website, I had to use Ctrl+c because right clicking shows that this is not simple HTML.
One is valid (the first), but the second gives VB fits as shown below. Either it won't compile (shown by the blue line below) or a simple assignment (the second one) wrecks havok on my form.
I have tried using
vectorString.Replace("–", "-")
and pasting in the longer dash for the target string and a normal keystroke dash as the replacement, but nothing happens. I'm guessing that since they both have the same Unicode.
Is there some way to convert the longer, invalid dash into the one recognized by VB? I tried using dash symbol that Word likes to replace the minus sign with and it comes up as Unicode 150. So, apparently there are at least three different kinds of dashes. Any thoughts?
The character from Math Insight is U+2212, minus sign. The character you tried using in your Replace call is U+2013, en dash. That's why your replace didn't work.
Beyond the standard ASCII hyphen (-, U+0045), there are two common dashes: the en dash (–, U+2013) and the em dash (—, U+2014). There is also a figure dash (‒, U+2012), but it is not as common.
I have an sqlite database with thousands of text entries. The text has many invisible/hidden carriage returns which shows the text in one long line. It displays okay on some programs, and on others it does not like this. If I just delete these hidden carriage returns and replace them by hitting the 'enter' button, everything works just fine. My question is how do I replace these hidden characters (which I believe are CHAR(13) or CHAR(10)) with a normal carriage return like I hit the enter button. What would the correct SQLite query be? I've found of examples about just replacing them all with an empty space but nothing about replacing with a normal paragraph.
Here is an example of what I mean:
-Result from growth in wool production in England- Enclosures were lands that were previously farms and they were turned into pastures for sheep- The serfs who had been working on the previous farm land were evicted
This is what I would like it to display:
Result from growth in wool production in England
Enclosures were lands that were previously farms and they were turned into pastures for sheep
The serfs who had been working on the previous farm land were evictedd
I can do this by just going and deleting these hidden carriage returns and hitting the enter button. I could do this for the entire database, but it would take me about 3 months to do that.
Any help would be most appreciated.
"Normal" line break depends on application. Indeed, different OS use different line breaks.
I would, first, get sure to have all line breaks normalized in your database - I prefer a single LF (x'0A'), so I would ensure my data uses only this character:
UPDATE mytable SET mycol=REPLACE(REPLACE(mycol, x'0D0A', x'0A'), x'0D', x'0A');
This would convert all CR+LF to LF, them all remaining CR to LF also.
Then convert output as desired for my application:
SELECT mycol FROM mytable; -- LF, Unix like systems, ...
SELECT REPLACE(mycol, x'0A', x'0D0A'); -- CRLF, Windows systems, ...
SELECT REPLACE(mycol, x'0A', x'0D'); -- CR, Mac OS (ver<=9), ...
I was given a task to encrypt a string, but I must create my own encryption techniques.
I have an idea of how to do it. I can associate each value in a string with a number, like so:
A = 0
B = 1
...
And then I want to substitute characters for digits in the tens and higher: if I enter the string "DOG" it must display
3.46 // . is 1 and .. is 2
// .4 is 14
I would like hear your ideas.
I was given a visual basic form to work on. I can enter a string; that is fine.
Input = txtInputString.Text
But I also have to decrypt a string. To show I want to decrypt the string I have to have
string, false
, the false showing that i want to decrypt the string. How do i do this?
Encryption and decryption of simple English text is fairly quite forward if you use a simple method such as Ceasar Cipher.
However you have to determine how you are going to represent all of the symbols in the language. This would include not only letters but digits and spaces and maybe punctuation as well.
The standard ASCII character set has most of what you might need for English the question is whether you want to simplify your alphabet by restricting your symbols to only upper case letters, digits, and a space. Human beings can usually read text, especially short text even if it does not have punctuation.
The approach for a simple cipher would be to have a table of the symbols in your alphabet (the upper case letters, digits zero through nine, and a space character). Next rearrange the table so that it is not in sorted order.
When doing an encrypt you would take each character, look it up in the table and determine a two digit offset within the table. This two digit number would be the encryption symbol for that character and is what you would write out as part of the string of encryption.
When doing a decrypt you would take each two digit pair and use that as an offset into the table, find the character at that location in the table, and the write the character from the table out as part of the string of decryption.
Your encrypted string would be a series of two digit pairs all strung together as one long number.
For your form, I would expect to have two text entry groups each with a button, a text entry field, and a text display field. The first group would be for the text to encrypt and that button you would press to perform an encrypt once the text is entered. The encryption text would display in the field below the text entry field.
The second group would be the text to decrypt and that button you would press to perform a decrypt.