06-24-2023, 07:32 PM
(06-24-2023, 04:45 PM)TerryRitchie Wrote: Is there any way to have code forum posts preserve all ASCII characters in the 32 to 255 range? For example, often times in my code I'll comment depictions of formulas as ASCII art in my code. I usually embed extended ASCII characters in them for readability. The code box below shows the result of this, versus the picture I included showing what it actually looks like.
Code: (Select All)SUB Rotate (vec AS Type_Vector2, angleDeg AS SINGLE, origin AS Type_Vector2)
' Rotate a point around an origin using linear transformations.
'
' Rotating from (x,y) to (x',y') |
' | (x',y') : L = R cosé | All of this shows how to get to this
' | ù : A = x' | -----------
' | /.\ : B = L cosè = R cosè cosé = x cosé | |
' | / .è\ : (note - * opposite angles are equal) | |
' | / . \ : C = R siné | +----+
' | / . \ : D = C sinè = R sinè siné = y siné | |
' | / . \ : Y = R sinè | |
' | / . \C : X = r cosè |
' | / . \ __ | -----------------
' | / . \ L stops : x' = B - |AB| = X cosé - Y siné |
' | / . \ here
' | / . \ | All of this just to show how to get from x to x' using (X cosé - Y siné)
' | / . \ | Use the same linear transformation methods to get y' using (X siné + Y cosé)
' | R/ . \ |
' | / .¿ D \ Change the origin point of all rotations to (0,0) by subtracting the current
' | / .------------âù_--ù (x,y) origin point from the current vector length. Add it back when rotation is
' | / . __--. . completed.
' | / . * __-- . .
' | / . __-- . .
' | / L __-- . .
' | / __-- . . .Y
' | / __-- * . . .
' | / __-- . . .
' | / é __-- . . .
' |/__-- è â. . .
' ù-----------------------ù-------------ù---ù------------
' A B
' |------------------- X -------------------|
DIM x AS SINGLE
DIM y AS SINGLE
DIM __cos AS SINGLE
DIM __sin AS SINGLE
DIM xPrime AS SINGLE
DIM yPrime AS SINGLE
x = vec.x - origin.x ' move rotation vector origin to 0
y = vec.y - origin.y
__cos = COS(_D2R(angleDeg)) ' get cosine and sine of angle
__sin = SIN(_D2R(angleDeg))
xPrime = (x * __cos) - (y * __sin) ' calculate rotated location of vector
yPrime = (x * __sin) + (y * __cos)
xPrime = xPrime + origin.x ' move back to original origin
yPrime = yPrime + origin.y
vec.x = xPrime ' pass back rotated vector
vec.y = yPrime
END SUB
Unfortunately not with Forum codeboxes or Wiki examples.
Why?
Because the IDE uses ANSI codepages, hence to get all chars displayed correctly in the Forum/Wiki webpages it would require the extended ASCII chars (128-255) to be encoded as UTF-8. That's actually what is done when exporting to a HTML/RTF document, as those are usually not copied back to the IDE.
However, doing that for the Forum/Wiki exports would actually display those chars correctly in the browser, but if someone uses the 'Select all' button to copy and paste the examples back into the IDE these UTF chars are not converted back to the IDE codepage representation, i.e. the chars would then be wrong in the IDE and could lead to syntax errors.
As the intention of codeboxes/wiki examples is, that people can easily copy/paste the code to try it out, I've waived to the UTF-8 encoding here, but that causes the chars to be displayed wrong in the browser. However, when selected and copied back into the IDE they are right again.
GuiTools, Blankers & other Projects:
https://staging.qb64phoenix.com/forumdisplay.php?fid=32
Libraries & useful Functions:
https://staging.qb64phoenix.com/forumdisplay.php?fid=23
https://staging.qb64phoenix.com/forumdisplay.php?fid=32
Libraries & useful Functions:
https://staging.qb64phoenix.com/forumdisplay.php?fid=23