Character recognition "-" Odd Behavior When Imported from Excel

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
Ryan Freund

Ryan Freund

19 сообщений из 339 понравились пользователям.

Группа: User

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 раз(а).


Character Import Problem - Dash.jpg
#2 Опубликовано: 15.11.2022 04:11:01
Martin_B

Martin_B

21 сообщений из 84 понравились пользователям.

Группа: User

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.
#3 Опубликовано: 15.11.2022 13:51:04
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

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 раз(а).

Clipboard01.png

Best regards.
Alvaro.
1 пользователям понравился этот пост
sergio 15.11.2022 16:04:00
#4 Опубликовано: 15.11.2022 18:06:35
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

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
2022-11-15 22_17_29-SMath Solver 1.0.8253 - [uchar.sm].png
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
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote

There is another brute force option for character to unicode number - findstr(). ...



Hi Martin. That's the technique adopted for this function here.

Clipboard01.png

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
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

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
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

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.
#8 Опубликовано: 16.11.2022 22:48:09
Ryan Freund

Ryan Freund

19 сообщений из 339 понравились пользователям.

Группа: User

Thanks for all the replies, very helpful. Makes sense now.
#9 Опубликовано: 03.03.2023 16:39:31
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

74 сообщений из 164 понравились пользователям.

Группа: User

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:
toDec(el(strsplit(substr(x,1,1),"\",2))
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:

Показать спойлер



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
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений