1 страниц (9 вхождений)
Character recognition "-" Odd Behavior When Imported from Excel - The "-" is not recognized as expected when imported from excel - Сообщения
#1 Опубликовано: 14.11.2022 18:20:01
I observed some unexpected behavior when using characters imported from excel. I have a "-" in the cell of an excel sheet which is imported into SMath. When I use this character in an if statement it does not find it to be equivalent to the "-" character in SMath. I'm guessing that it might have something to do with the cell format in excel, but I can't see what sort of information is following this character into SMath. Any idea what SMath is reading the two 'different' dashes "-" as?
Refer to the attached Smath File:
Steel Worksheet - Test.sm (9 КиБ) скачан 27 раз(а).

Refer to the attached Smath File:
Steel Worksheet - Test.sm (9 КиБ) скачан 27 раз(а).
#2 Опубликовано: 15.11.2022 04:11:01
In Excel you used the charakter 2013 (hex), which is the short dash (en-dash): –
If you use the keyboard you will enter the charakter 002D, which is the "hyphen-minus": -
They only look very similar in SMath. But you can notice, that the hyphen-minus is slightly thicker.
If you use the keyboard you will enter the charakter 002D, which is the "hyphen-minus": -
They only look very similar in SMath. But you can notice, that the hyphen-minus is slightly thicker.
#3 Опубликовано: 15.11.2022 13:51:04
Hi. As MarB says, Excel have it's own things. This function could be useful to try to know what character it is, although it can be very slow if its unicode is large, in addition to also presenting inconveniences if the character is typed or pasted, which I do not understand well.
Steel Worksheet - uchar.sm (16 КиБ) скачан 31 раз(а).

Best regards.
Alvaro.
Steel Worksheet - uchar.sm (16 КиБ) скачан 31 раз(а).
Best regards.
Alvaro.
1 пользователям понравился этот пост
sergio 15.11.2022 16:04:00
#4 Опубликовано: 15.11.2022 18:06:35
There is another brute force option for character to unicode number - findstr().
The benefit of the approach is that once the search target is built, the search is reasonable fast (0.015 s), you only see it when the calculation runs without problems.
BTW, don't try to display S, this produces a soft crash in both versions.
Also, hovering over the definition of S produces a soft crash, due to the attempt to preview the contents.
uchar.sm (20 КиБ) скачан 26 раз(а).
![2022-11-15 21_55_01-SMath Solver - [Steel Worksheet - uchar.sm_].png](/ru-RU/file/P3QgAK/2022-11-15-21_55_01-SMath-Solver---_Steel-Worksheet---uchar_sm___png)
![2022-11-15 22_17_29-SMath Solver 1.0.8253 - [uchar.sm].png](/ru-RU/file/FyWyKs/2022-11-15-22_17_29-SMath-Solver-1_0_8253---_uchar_sm__png)
The benefit of the approach is that once the search target is built, the search is reasonable fast (0.015 s), you only see it when the calculation runs without problems.
BTW, don't try to display S, this produces a soft crash in both versions.
Also, hovering over the definition of S produces a soft crash, due to the attempt to preview the contents.
uchar.sm (20 КиБ) скачан 26 раз(а).
Martin Kraska
Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 пользователям понравился этот пост
sergio 16.11.2022 06:00:00
#5 Опубликовано: 15.11.2022 19:36:25
WroteThere is another brute force option for character to unicode number - findstr(). ...
Hi Martin. That's the technique adopted for this function here.
Unfortunately N.256 requires some adjustment as it cannot properly save the characters less than 32.
However, I think that a function like uchar could be much more practical and stable in a C# plugin, perhaps in SpecialFunctions or some other similar.
Best regards.
Alvaro.
1 пользователям понравился этот пост
sergio 16.11.2022 06:00:00
#6 Опубликовано: 16.11.2022 04:46:26
Wrote
Hi Martin. That's the technique adopted for this function here.
I usually ignore forum posts without visual teaser

Yes, I agree, this would be a good candidate for an internal function.
Martin Kraska
Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 пользователям понравился этот пост
Alvaro Diaz Falconi 16.11.2022 13:35:00
#7 Опубликовано: 16.11.2022 14:02:37
Hi. Some notes about strings in SMath
Distribution: It could be that the functions for strings will be distributed in a dll strings.dll in the default SMath/plugins installation directory
Naming convention: All string function names have “str” somewhere, except concat, ucfirst ucwords, and few others. It would be interesting if all new functions also have "str" somewhere in the name.
Other functions to add:
- ascii and Unicode utilities, maybe returning vectors like Mathcad str2vec
- padding and stripping blanks
- comparisons between strings with options for case sensitive or not
- questions like strIsLetter or strIsNumber
- regular and expressions and matching patterns utilities
- base conversions
- ...
Best regards.
Alvaro.
Distribution: It could be that the functions for strings will be distributed in a dll strings.dll in the default SMath/plugins installation directory
Naming convention: All string function names have “str” somewhere, except concat, ucfirst ucwords, and few others. It would be interesting if all new functions also have "str" somewhere in the name.
Other functions to add:
- ascii and Unicode utilities, maybe returning vectors like Mathcad str2vec
- padding and stripping blanks
- comparisons between strings with options for case sensitive or not
- questions like strIsLetter or strIsNumber
- regular and expressions and matching patterns utilities
- base conversions
- ...
Best regards.
Alvaro.
#8 Опубликовано: 16.11.2022 22:48:09
Thanks for all the replies, very helpful. Makes sense now.
#9 Опубликовано: 03.03.2023 16:39:31
Greetings,
The following is a bit of a 'trick' that I just discovered: Smath will convert some of the characters within a string to its HEX value:
Where 'toDec() is a custom function that converts HEX string to a decimal, and the variable 'x' would be the character in question.
Below is the code for a working function (just copy and paste into your Worksheet):
Just be aware, this function is limited; there is no shortage of characters that will fail to return a result (This function will NOT work for Alphanumeric, Letters with Accents, Latin, etc.), some of which are shown below:
01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]ghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼʽʾʿˀˁˆˇˈˉˊˋˌˍˎˏːˑˠˡˢˣˤˬˮͰͱͲͳʹͶͷͺ [...]
Since this function isn't guaranteed to return a result (but only takes 0.01sec), you could implement it as a precursory check to the more time-consuming UChar(x) method.
Hope this is of assistance,
-Kenny Lemens, P.E. ᵂᴵ
The following is a bit of a 'trick' that I just discovered: Smath will convert some of the characters within a string to its HEX value:
toDec(el(strsplit(substr(x,1,1),"\"
,2))
Below is the code for a working function (just copy and paste into your Worksheet):
AscW(_str):line("Very\0020\Fast\0020\\0028\0\002E\01sec\0029\\002C\\0020\but\0020\only\0020\works\0020\for\0020\select\0020\characters\0020\\0028\Does\0020\NOT\0020\support\0020\Greek\002C\\0020\Alphanumeric\002C\\0020\etc\002E\\002E\\002E\\0029\\000A\\007B\0\007D\\0020\as\0020\String\003B\\0020\attempts\0020\to\0020\convert\0020\the\0020\1st\0020\character\0020\in\0020\string\0020\to\0020\its\0020\ASCII\0020\value\002C\\0020\as\0020\a\0020\Decimal\003B\\0020\Will\0020\throw\0020\an\0020\ERROR\0020\on\0020\bad\0020\input\002E\\000A\per\0020\conversation\0020\on\0020\\0028\https\003A\\002F\\002F\en\002E\smath\002E\com\002F\forum\002F\yaf\005F\postst23239\005F\Character\002D\recognition\002D\\002D\\002D\\002D\\002D\Odd\002D\Behavior\002D\When\002D\Imported\002D\from\002D\Excel\002E\aspx\0029\\0020\\000A\\002D\\0020\Author\003A\\0020\Kenny\0020\Lemens\0020\2023\002D\03\002D\03",toDec(_hex):line("[String]\0020\Converts\0020\the\0020\hexidecimal\0020\in\0020\string\003A\\007B\0\007D\\0020\and\0020\returns\0020\an\0020\integer\002E\\000A\\0020\https\003A\\002F\\002F\smath\002E\com\002F\wiki\002F\GetFile\002E\aspx\003F\File\003D\graphs\0025\2fRGB\002D\RGBA\0025\20colors\002E\zip\0020\\000A\\0020\\0028\Authors\003A\\0020\smath\002C\\0020\oscampo\002C\\0020\w3b5urf3r\0029\",output:0,aryHex:"0123456789ABCDEF",count:strlen(_hex),for(k:1,k≤count,k:k+1,line(num:el(findstr(aryHex,substr(_hex,k,1)),1)-1,output:output+num*16^{count-k},2,1)),output,6,1),errMsg:concat("Unkown\0020\error\002E\\002E\\002E\\0020\unable\0020\to\0020\parse\0020\\0020\param\0020\\007B\0\007D\\0020\\003D\\0020\",var2str(_str)),strChar:substr(_str,1,1),try(line(tmpVal:strsplit(strChar,"\"
,if(rows(tmpVal)>1,returnVal:toDec(el(tmpVal,2)),error(errMsg:"Character\0020\is\0020\Not\0020\Supported\0020\via\0020\this\0020\method\002E\\002E\\002E\"
),2,1),error(errMsg)),5,1)
Just be aware, this function is limited; there is no shortage of characters that will fail to return a result (This function will NOT work for Alphanumeric, Letters with Accents, Latin, etc.), some of which are shown below:
01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]ghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼʽʾʿˀˁˆˇˈˉˊˋˌˍˎˏːˑˠˡˢˣˤˬˮͰͱͲͳʹͶͷͺ [...]
Since this function isn't guaranteed to return a result (but only takes 0.01sec), you could implement it as a precursory check to the more time-consuming UChar(x) method.
Hope this is of assistance,
-Kenny Lemens, P.E. ᵂᴵ
"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
1 страниц (9 вхождений)
-
Новые сообщения
-
Нет новых сообщений