String Encoding

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

#1 Publicado: 15/8/2023 0:18:03
Peter Johns

Peter Johns

2 me gusta en 11 mensajes.

Grupo: 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 Publicado: 15/8/2023 0:31:40
Peter Johns

Peter Johns

2 me gusta en 11 mensajes.

Grupo: 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.
A 2 usuarios les gustó este mensaje
Martin Kraska 15/8/2023 14:30:00, ⚜ Kenny Lemens, P.E. ᵂᴵ 15/8/2023 15:22:00
#3 Publicado: 15/8/2023 13:07:12
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

85 me gusta en 181 mensajes.

Grupo: 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
A 1 usuarios les gustó este mensaje
Oscar Campo 15/8/2023 13:14:00
#4 Publicado: 15/8/2023 14:32:31
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: 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 Publicado: 15/8/2023 15:27:26
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: 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) descargado 1388 vez(es).
  • Nuevos mensajes
  • Sin mensajes nuevos