String Encoding

String Encoding - Is it possible to enforce a single method of string encoding or convert between encoding standards - Messages

#1 Posted: 8/15/2023 12:18:03 AM
Peter Johns

Peter Johns

2 likes in 11 posts.

Group: 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 Posted: 8/15/2023 12:31:40 AM
Peter Johns

Peter Johns

2 likes in 11 posts.

Group: 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 users liked this post
Martin Kraska 8/15/2023 2:30:00 PM, ⚜ Kenny Lemens, P.E. ᵂᴵ 8/15/2023 3:22:00 PM
#3 Posted: 8/15/2023 1:07:12 PM
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

74 likes in 164 posts.

Group: 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 users liked this post
Oscar Campo 8/15/2023 1:14:00 PM
#4 Posted: 8/15/2023 2:32:31 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: 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 Posted: 8/15/2023 3:27:26 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: 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 KiB) downloaded 24 time(s).
  • New Posts New Posts
  • No New Posts No New Posts