Per HTTP URL spec (http://tools.ietf.org/html/rfc3986#page-16), the fragment id ('#' bit) should appear last in the url and terminates the query (or search) string
Ie. in your failing url -
http://www.dokuwiki.org/doku.php?id=page#anchor&myarg=true
- the query string (?var1=val2&var2=val2 portion) ends when the '#' is encountered, so the correct query string is "id=page"
- there are restrictions on the characters that can make up a fragment id, so I suspect the fragment id is assumed to be ''anchor" rather than "anchor&myarg=true".