<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>1517</bug_id>
          
          <creation_ts>2025-07-07 09:40:19 +0200</creation_ts>
          <short_desc>Invalid charset for JOAL Strings</short_desc>
          <delta_ts>2025-07-08 13:42:22 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Joal</product>
          <component>core</component>
          <version>2.6.0</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P4</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mathieu Féry (MathiusD)">mfery</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          
          
          <cf_type>DEFECT</cf_type>
          <cf_scm_refs>ca08b5ab2d64f23331580dcb9b9e0a2b807e4608</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>7196</commentid>
    <comment_count>0</comment_count>
    <who name="Mathieu Féry (MathiusD)">mfery</who>
    <bug_when>2025-07-07 09:40:19 +0200</bug_when>
    <thetext>When we fetching string with alcGetString and alcGetStringAsDoubleNullTerminatedString, we retrieve strings with wrong charset.

Since theses strings can be used to select the audio device, this can be annoying :c

Atm we can work around this issue if we retrieve JOAL strings with UTF-8 charset instead the US-ASCII charset (Maybe it&apos;s related of openal-soft build or maybe after the migration to java 11?).

We have reproduced this issue on Fedora Linux 42 &amp; Windows 10

Tested with 2 followings RC :
 * https://jogamp.org/deployment/v2.6.0-rc-20250706/jar/
 * https://jogamp.org/deployment/v2.6.0-rc-20250628/jar/

With following call :
 * java -cp joal.jar:joal-natives-linux-amd64.jar:joal-test.jar:gluegen-rt.jar:gluegen-rt-natives-linux-amd64.jar com.jogamp.openal.test.manual.ALCSystemEventTest for Fedora Linux 42
 * java -cp joal.jar:joal-natives-windows-amd64.jar:joal-test.jar:gluegen-rt.jar:gluegen-rt-natives-windows-amd64.jar com.jogamp.openal.test.manual.ALCSystemEventTest for Windows 10

If I&apos;ve forgotten anything or if I can help, don&apos;t hesitate!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7198</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2025-07-07 21:26:45 +0200</bug_when>
    <thetext>Do I understand you correctly that:
- We interpret the returned string hard decoded as US-ASCII?
  - This is true for e.g. alcGetString in our source code.
- The actual produced device string is UTF-8 and hence the wrong decoding &apos;ruins&apos; the data?

Notes:
- The OpenAL manual doesn&apos;t mention encoding.
- OpenAL-Soft uses std::string and seems not to apply special encoding
- std::string can contain UTF-8 as long one safely uses the given byte length
- c-str ASCII `strlen` uses codepoint `\0` (EOS null-byte) and no UTF-8 codepoint producses it (no collision)

If above is true, we could simply use UTF-8 in our Java code from the byte array,
which is compatible w/ US-ASCII.

OK?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7199</commentid>
    <comment_count>2</comment_count>
    <who name="Mathieu Féry (MathiusD)">mfery</who>
    <bug_when>2025-07-08 09:23:28 +0200</bug_when>
    <thetext>(In reply to Sven Gothel from comment #1)

&gt; Do I understand you correctly that:
&gt; - We interpret the returned string hard decoded as US-ASCII?
&gt;   - This is true for e.g. alcGetString in our source code.

Yes, for alcGetString and alcGetStringAsDoubleNullTerminatedString in src/java/jogamp/openal/ALCImpl.java

&gt; - The actual produced device string is UTF-8 and hence the wrong decoding &apos;ruins&apos; the data?

Yes for example in my case i have theses names of devices :
&gt; Capture devices:
&gt;    Audio interne St��r��o analogique, input, default true
&gt;    Monitor of Audio interne St��r��o analogique, input, default false
&gt;    Monitor of HDA NVidia St��r��o num��rique (HDMI), input, default false

Instead of this with UTF-8 charset :
&gt; Capture devices:
&gt;    Audio interne Stéréo analogique, input, default true
&gt;    Monitor of Audio interne Stéréo analogique, input, default false
&gt;    Monitor of HDA NVidia Stéréo numérique (HDMI), input, default false

And since we can retrieve a device with the name, a wrong encoding &apos;break&apos; opening of device related (Example in my case)
&gt; Error: Failed to open default output device Audio interne St��r��o analogique
&gt; Error: Failed to open output device HDA NVidia St��r��o num��rique (HDMI)

&gt; If above is true, we could simply use UTF-8 in our Java code from the byte array,
&gt; which is compatible w/ US-ASCII.
&gt; 
&gt; OK?

Yes, that&apos;s the workaround I used and from what you describe in your notes it seems safe to use, so it sounds like the right solution to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7200</commentid>
    <comment_count>3</comment_count>
      <attachid>894</attachid>
    <who name="Mathieu Féry (MathiusD)">mfery</who>
    <bug_when>2025-07-08 09:26:45 +0200</bug_when>
    <thetext>Created attachment 894
Patch used in my case to work around this issue (For reference)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7201</commentid>
    <comment_count>4</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2025-07-08 12:36:47 +0200</bug_when>
    <thetext>(In reply to Mathieu Féry (MathiusD) from comment #3)
Perfect, thx.

Shall I do a git pull/merge or apply your patch &apos;manually&apos;?

~Sven</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7202</commentid>
    <comment_count>5</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2025-07-08 12:39:40 +0200</bug_when>
    <thetext>(In reply to Sven Gothel from comment #4)
OK, will use your patch and commit with you as author. 
Guess that&apos;s the fastest best way :)

Thank you!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7203</commentid>
    <comment_count>6</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2025-07-08 12:44:06 +0200</bug_when>
    <thetext>commit ca08b5ab2d64f23331580dcb9b9e0a2b807e4608
done</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7204</commentid>
    <comment_count>7</comment_count>
    <who name="Mathieu Féry (MathiusD)">mfery</who>
    <bug_when>2025-07-08 13:42:22 +0200</bug_when>
    <thetext>Thanks a lot !</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>894</attachid>
            <date>2025-07-08 09:26:45 +0200</date>
            <delta_ts>2025-07-08 09:26:45 +0200</delta_ts>
            <desc>Patch used in my case to work around this issue (For reference)</desc>
            <filename>joal-charset-encoding.patch</filename>
            <type>text/plain</type>
            <size>1079</size>
            <attacher name="Mathieu Féry (MathiusD)">mfery</attacher>
            
              <data encoding="base64">SW5kZXg6IHNyYy9qYXZhL2pvZ2FtcC9vcGVuYWwvQUxDSW1wbC5qYXZhCjwrPlVURi04Cj09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT0KZGlmZiAtLWdpdCBhL3NyYy9qYXZhL2pvZ2FtcC9vcGVuYWwvQUxDSW1wbC5qYXZhIGIv
c3JjL2phdmEvam9nYW1wL29wZW5hbC9BTENJbXBsLmphdmEKLS0tIGEvc3JjL2phdmEvam9nYW1w
L29wZW5hbC9BTENJbXBsLmphdmEJKHJldmlzaW9uIGU1ZTA2YzMxNjlmZTUzN2IxNWM1ZWM4NmM2
YzAzMmM3ZWM1Mjc0M2IpCisrKyBiL3NyYy9qYXZhL2pvZ2FtcC9vcGVuYWwvQUxDSW1wbC5qYXZh
CShkYXRlIDE3NTE5NTg3Mjk3NzApCkBAIC01Myw3ICs1Myw3IEBACiAgICAgICAgIGZpbmFsIGJ5
dGVbXSByZXMgPSBuZXcgYnl0ZVtidWYuY2FwYWNpdHkoKV07CiAgICAgICAgIGJ1Zi5nZXQocmVz
KTsKICAgICAgICAgdHJ5IHsKLSAgICAgICAgICAgIHJldHVybiBuZXcgU3RyaW5nKHJlcywgIlVT
LUFTQ0lJIik7CisgICAgICAgICAgICByZXR1cm4gbmV3IFN0cmluZyhyZXMsICJVVEYtOCIpOwog
ICAgICAgICB9IGNhdGNoIChmaW5hbCBVbnN1cHBvcnRlZEVuY29kaW5nRXhjZXB0aW9uIGUpIHsK
ICAgICAgICAgICAgIHRocm93IG5ldyBBTEV4Y2VwdGlvbihlKTsKICAgICAgICAgfQpAQCAtMTEx
LDcgKzExMSw3IEBACiAgICAgICAgICAgICAgICAgd2hpbGUgKChpIDwgYnl0ZXMubGVuZ3RoKSAm
JiAoYnl0ZXNbaV0gIT0gMCkpIHsKICAgICAgICAgICAgICAgICAgICAgaSsrOwogICAgICAgICAg
ICAgICAgIH0KLSAgICAgICAgICAgICAgICByZXMuYWRkKG5ldyBTdHJpbmcoYnl0ZXMsIHN0YXJ0
SW5kZXgsIGkgLSBzdGFydEluZGV4LCAiVVMtQVNDSUkiKSk7CisgICAgICAgICAgICAgICAgcmVz
LmFkZChuZXcgU3RyaW5nKGJ5dGVzLCBzdGFydEluZGV4LCBpIC0gc3RhcnRJbmRleCwgIlVURi04
IikpOwogICAgICAgICAgICAgICAgIGkrKzsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIHJl
dHVybiAoU3RyaW5nW10pIHJlcy50b0FycmF5KG5ldyBTdHJpbmdbcmVzLnNpemUoKV0pOwo=
</data>

          </attachment>
      

    </bug>

</bugzilla>