|
Post by Robert on Nov 23, 2023 13:32:47 GMT -5
George,
Right now, there are no SPF-supplied functions to do EBCDIC translation, and thinBasic has none either. This suggestion describes a possible implementation.
Current thinBasic translation functions are named like,
object-str = SourceToObject$(source-str)
For instance,
UTF8_str = AnsiToUtf8$(ansi_str)
But, SPFLite function names that return strings have names that begin with Get. So, to be SPFLite-consistent instead of thinBasic consistent, we need to follow that naming pattern.
Here are the proposed functions:
ebcdic-str = Get_EBCDIC_from_ANSI$ (ansi-str)
ansi-str = GET_ANSI_from_EBCDIC$ (ebcdic-str)
Description:
SPFLite maintains internal translation tables, based on its reading of the EBCDIC.SOURCE translation file. Those internal tables would be used to perform the translation in these new functions.
It is not an error if the supplied string value is null (""); it would simply return a null "" string back.
R
|
|
|
Post by George on Nov 28, 2023 11:28:26 GMT -5
Robert: They should be simple to add. Get_ANSI2EBCDIC$ and Get_EBCDIC2ANSI$ might be a bit shorter, knowing how you hate to type.
George
|
|
|
Post by Robert on Nov 28, 2023 12:16:33 GMT -5
I looked at the SPFLite source code. I *think* it's possible to lift all the source-file parser code (which I wrote many moons ago) and convert it to thinBasic, but if you're willing to do this, great.
I do hate to type, but using "2" to mean "to", it doesn't actually make sense, grammatically. Maybe you are changing ANSI to EBCDIC, but you're not "getting" ANSI from EBCDIC. "2" makes the name confusing, IMO.
It turns out, after some looking, that TB already has a "translate" function, called REPLACE$. So, instead of these functions actually doing translation, all that's really needed is returning the tables as 256-byte strings.
That would give,
str = Get_ANSI2EBCDIC_TranTab$ and str = Get_EBCDIC2ANSI_TranTab$
I believe that would be enough.
R
|
|
|
Post by George on Dec 1, 2023 13:31:54 GMT -5
Robert: Should this be renamed? I know 99.999% of SOURCE settings are ANSI or EBCDIC. But SOURCE is generalized so the tables returned are really ANSI to SOURCE and SOURCE to ANSI.
Do we acknowledge that? Or just go with the two majority values?
George
|
|
|
Post by Robert on Dec 1, 2023 13:35:30 GMT -5
I had a similar thought. Really, the internal tables in SPFLite are SOURCE to (non-source) I believe. So, yes, Get_SOURCE2EBCDIC_TranTab$() and Get_EBCDIC2SOURCE_TranTab$() are probably more "correct".
We are, technically, supporting non-ANSI versions of ASCII. People in non-north American countries might not necessarily be using ANSI.
R
Oops, this is hard to keep straight. "SOURCE" in EBCDIC mode is EBCDIC, and Edit mode always edits in ANSI. So, the translation is always between ANSI and something else. I think the names you first said were right.
Sheesh.
R
|
|
|
Post by George on Dec 1, 2023 13:54:42 GMT -5
Yes, it gets confusing. When I was testing and displayed the tables I retrieved, I had to sit and think about whether I'd passed the correct ones, or had got it reversed.
I'll make them: Get_ANSI2SOURCE_Table$ Get_SOURCE2ANSI_Table$
Is that OK?
George
|
|
|
Post by Robert on Dec 1, 2023 14:13:16 GMT -5
Yes
|
|