[mapguide-users] extended characters with .NET

Darren Karasiuk darren.karasiuk at aldatasoftware.com
Mon Mar 16 15:48:21 EDT 2009


I was able to get the correct extended characters to work with .NET editing
XML.

The problem was how strings were handled.

I changed the function "add_layer_definition_to_map" to take the entire
XMLDocument object, then read and count the number of bytes to pass to the
"byteSource" variable.
The code provided in the API documentation used:
	Dim encoding As New System.Text.ASCIIEncoding()
I changed this to:
	encoding As New System.Text.UTF8Encoding()
and the necessary byte reading and counting code.

Here is the function as I have it. Note that an XMLDocument is being passed
in.


Public Function add_layer_definition_to_map(ByVal layerDefinition As
XmlDocument, ByVal layerName As String, ByVal layerLegendLabel As String) As
MgLayer
        'Validate the XML
        Dim XmlDoc As New XmlDocument
        'XmlDoc.LoadXml(layerDefinition)
        'don't understand validation yet

        Dim encoding As New System.Text.UTF8Encoding() 'Changed!
        Dim rawbytes As Byte() =
encoding.GetBytes(layerDefinition.OuterXml.ToString) ' Added!
        Dim byteSource As New MgByteSource(rawbytes, rawbytes.Length)
'Changed!
        byteSource.SetMimeType(MgMimeType.Xml)
        Dim resourceID As New MgResourceIdentifier("Session:" + mgSessionID
+ "//" + layerName + ".LayerDefinition")
        resourceservice.SetResource(resourceID, byteSource.GetReader,
Nothing)
        Dim newLayer As MgLayer = add_layer_resource_to_map(resourceID,
layerName, layerLegendLabel)

        Return newLayer
    End Function




Darren Karasiuk
ALDATA Software Management

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Darren Karasiuk
Sent: March 13, 2009 10:21 AM
To: 'MapGuide Users Mail List'
Subject: RE: [mapguide-users] extended characters with .NET

Well, I'm still having trouble with getting characters above 127 to work
with .NET. I've tried using different fonts but the images don't appear on
the map. (-.-;)

I've searched for symbol resources but couldn't find any. Is there an easy
way of making a symbol without having MapGuide Enterprise?


-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Aldata
Sent: March 11, 2009 4:50 PM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] extended characters with .NET


Hi everyone,
I have a problem with using extended characters with fonts.

When I create a layer with Autodesk Map Guide Studio and use a Wingdings
arrow as the point style, there is no problem.
I load the exported xml layer.definition in my .NET application, change the
filter, save the resource, and add the layer to the the map.  At this point,
the data loads and plots successfully, but the point style that is expected
to be an arrow, is now a picture of hand holding a pen, the equivalent of a
the question mark (?) in a normal text font.

I figure it's .NET converting the UTF-8 character into ASCII or UNICODE that
is trouble.  The Webdings font works fine up until character decimal 127.
After that, the hand holding a pen again.

I tried to use the notation & #xE9; (space added so webpage doesn't
interpret) but again, no go. I also tried the decimal version with no
success.

How can I load, edit, and output layer.definition containing extended
characters using .NET?

What I have:
        Dim layerXMLDoc As XmlDocument = New XmlDocument()
        Dim XMLDocPath As String =
Server.MapPath("layerdef\trucks.LayerDefinition.xml")
        Dim sr As New IO.StreamReader(XMLDocPath, System.Text.Encoding.UTF8)
        layerXMLDoc.LoadXml(sr.ReadToEnd())
        sr.Close()
...
Dim newLayer As MgLayer = add_layer_definition_to_map(layerXMLDoc.OuterXml,
"layer-eq" + EquipmentList.SelectedValue.ToString,
EquipmentList.SelectedItem.ToString)
....
-----

This function was more or less copied from the api documents which receives
the layerXMLDoc as the first parameter.  Is the problem with out it's
passed?

 Public Function add_layer_definition_to_map(ByVal layerDefinition As
String, ByVal layerName As String, ByVal layerLegendLabel As String) As
MgLayer
        'Validate the XML
        Dim XmlDoc As New XmlDocument
        XmlDoc.LoadXml(layerDefinition)
        'don't understand validation yet

        Dim encoding As New System.Text.ASCIIEncoding() ' Is the problem
here???

        Dim byteSource As New
MgByteSource(encoding.GetBytes(layerDefinition.ToString),
layerDefinition.Length)
        byteSource.SetMimeType(MgMimeType.Xml)
....
-------

Thanks for your time!
-- 
View this message in context:
http://n2.nabble.com/extended-characters-with-.NET-tp2464283p2464283.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users

_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users



More information about the mapguide-users mailing list