String Encoding

String Encoding - Is it possible to enforce a single method of string encoding or convert between encoding standards - Сообщения

#1 Опубликовано: 15.08.2023 00:18:03
Peter Johns

Peter Johns

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

Группа: User

It appears that SMath can have text (strings) encoded using different standards in the same worksheet, or possibly it is just ambivalent to encoding standards (which makes sense).

This leads to the problem described by Martin in this post:

https://en.smath.com/forum/yaf_postst21885_String-compare-problem-with-different-encoding-schemes.aspx

My question:

In order to guarantee text strings can be compared, is it possible to either:

1 - Convert one text encoding scheme to another, so that both strings could be converted to the same scheme before being compared
2 - Have some other workaround for this problem

Thanks,
Peter
#2 Опубликовано: 15.08.2023 00:31:40
Peter Johns

Peter Johns

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

Группа: User

I have made two more discoveries since posting this:

Firstly, if I have two strings using different encoding schemes:

myString1:="myString"
myString2:="myString"

such that:

myString1 = myString2 = 0

then

substr(myString1,1) = substr(myString2,1) = 1

I assume that taking a sub-string of a string changes the encoding system (although I'm not sure why that would be the case). Is this correct? Is this a robust workaround, or might this not always be the case.

Secondly,

If you open and close the file then myString1 = myString2 = 1

I assume that closing and re-opening the file changes the encoding system (which make more sense), but is not a practicable work around.
2 пользователям понравился этот пост
Martin Kraska 15.08.2023 14:30:00, ⚜ Kenny Lemens, P.E. ᵂᴵ 15.08.2023 15:22:00
#3 Опубликовано: 15.08.2023 13:07:12
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

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

Группа: User

Greetings,

From a Plugin Standpoint, the encoding/decoding can be handelded through SMath.Manager.TermsConverter:
SMath.Manager.TermsConverter.EncodeText("text"
SMath.Manager.TermsConverter.DecodeText("text"

From a native solution, you can try using some of the other string functions (e.g., strtolower(), strtoupper()) to convert a string to the same scheme:
a:"mydString"="mydString"
b:"my\0064\String"="my\0064\String"
a≡b=0

a:strtolower("mydString"="mydstring"
b:strtolower("my\0064\String"="mydstring"
a≡b=1
I think your best option would be to use the substr() function, just call your strings and return the 'full' string as a substring (i.e., your starting index = 1), the result should be of the same text scheme:
asubstr("mydString",1))="mydString"
bsubstr("my\0064\String",1))="mydString"
a≡b=1

May this be of Good Help;
⚜ 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 пользователям понравился этот пост
Oscar Campo 15.08.2023 13:14:00
#4 Опубликовано: 15.08.2023 14:32:31
Martin Kraska

Martin Kraska

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

Группа: Moderator

Wrote

I have made two more discoveries since posting this:

Firstly, if I have two strings using different encoding schemes:

myString1:="myString"
myString2:="myString"

such that:

myString1 = myString2 = 0

then

substr(myString1,1) = substr(myString2,1) = 1

I assume that taking a sub-string of a string changes the encoding system (although I'm not sure why that would be the case). Is this correct? Is this a robust workaround, or might this not always be the case.



The substring workaround worked well for my Maxima test suite. No more inequality indication for visually identical strings. Thanks a lot!
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#5 Опубликовано: 15.08.2023 15:27:26
Jean Giraud

Jean Giraud

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

Группа: User

My understanding is that you want multiple Bolean
so to carry some intelligible project.
8 years old native string system.

Project GROCERY.sm (9 КиБ) скачан 24 раз(а).
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений