+ Reply to Thread
Results 1 to 4 of 4

Thread: XDoc encoding problem

  1. #1
    Join Date
    Jan 2011
    Posts
    49

    Default XDoc encoding problem

    Hello,

    I am currently programming an DreamService and my methods returns a XDoc.
    The problem is that i read a file that contain special caractors and when i render it all into a Xdoc, it will not consider the special caracters.

    So how can i force encoding Xdoc into UTF8 or somthing else? I didnt find anything on the XDoc Class documentation.

    Thank you for your help!

  2. #2
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    XDoc does all encoding automatically. Can you share a code snippet? Maybe you're running into a different issue than you think.
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  3. #3
    Join Date
    Jan 2011
    Posts
    49

    Default

    This is the header of the CS file:

    Code:
        [DreamService("Livelink Connector", "Frédéric Hanna 2011.",
                      SID = new string[] { "http://gps.ireq.ca/wiki/LivelinkConnector" }
        )]
        [DreamServiceBlueprint("deki/service-type", "extension")]
        [DekiExtLibrary(Namespace = "livelinkconnector",
            Label = "Livelink documents fetcher",
            Description = "This extension allow you to retreive some documents from Open Text Livelink.")]
        class LivelinkUtils : DekiExtService
        {
    
            /// <summary>
            /// Retreive document informations from an Livelink server and return result as XML.
            /// </summary>
            /// <param name="userAccount">User ID, ie: AA1234</param>
            /// <param name="attributes">Attributes to load (default: {givenname, sn} )</param>
            /// <returns>XML Representation of specified attributes values</returns>
            [DekiExtFunction(Description = "Displays all the publications of a user based on his id and formatted with the APA standards.")]
            public XDoc getUserPublications(
                [DekiExtParam("User ID, ie: AA1234")] string CIP
            )
    Here i read a file rendered in charset=iso-8859-1

    Code:
    readFile = new StreamReader(absolutePublicationsDirectory + CIP + EXTENSION_FICHIER, System.Text.Encoding.Default);
    
    
    while ((line = readFile.ReadLine()) != null)
     {
    //here i read each line and add it to a String Array 
    }
    Then i prepare the Xdoc

    Code:
                    for (int i = 0; i < nbDocuments; i++)
                    {
                        HTMLResult.Start("li").Start("a").Attr("href", publications[i, 1]).Value(publications[i, 0]).End().End();
                    }
    
    // here i return the Xdoc
                    HTMLResult.End();
    
                    return HTMLResult;

  4. #4
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    I think your problem is with System.Text.Encoding.Default. Make sure you use an encoding that can read your source file without losing characters (e.g. UTF8).
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts