String Encoding

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

#1 已发布: 2023/8/15 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 已发布: 2023/8/15 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 2023/8/15 14:30:00, ⚜ Kenny Lemens, P.E. ᵂᴵ 2023/8/15 15:22:00
#3 已发布: 2023/8/15 13:07:12
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

85个赞,共181个帖子。

组: 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 2023/8/15 13:14:00
#4 已发布: 2023/8/15 14:32:31
Martin Kraska

Martin Kraska

1,362个赞,共2,276个帖子。

组: 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!
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#5 已发布: 2023/8/15 15:27:26
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: 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.86 KiB)已下载 1407 次。
  • 有新帖
  • 无新帖