[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: How to store Newline character ?



Sorry, It didn't work in openLDAP. Replacing '\n' by '$' to preserve the
original newline characters doesn't seem to work for me. I am not sure
whether I am doing some stupidity or it really doesn't work in openLDAP.
While doing ldapsearch, it shows the '$' sign and also after extracting
the data via C api, it shows $. Doesn't seem to treat $ as any special
character.
Any Clues ???


Thanks
-Himanshu


On Wed, 28 Apr 1999, Jeff Clowser wrote:

> Not sure if this is an LDAP standard, or just Netscape's way of doing it (I'd have
> to look it up for sure), but they convert \n's to "$" characters to store in ldap.
> Anything that pulls it out has to change the '$''s back to \n to display.  Another
> option is to store each line as a separate value in the attribute.
> i.e.:
>
>      description: line1$line2$line3
>
> or
>
>      description: line1
>      description: line2
>      description: line3
>
> Course, the problem with the second is that I don't think you are guaranteed that
> LDAP will return them in the same order you store them in, so this is probably not
> a good for this example...  If you know your LDAP server always returns them in the
> same order, you could use this, but you risk problems if you replace or upgrade
> your ldap server and this breaks, so if order is important (as in this case) the
> first is safest.  Oh, yeah, if your lines contain dollar signs, you'd have to
> encode/decode them so you don't break lines in unexpected places.
>
>
> Himanshu wrote:
>
> > HI
> >         How do I store a newline character (\n) along with other ascii
> > characters in an attribute ?
> > Lets say I have an
> > attribute  Description
> > an the value
> > ---------------start of value--------
> > Used by: File server
> > CPU:        424M1739 UK B048407
> > Keyboard:   0039147-9413263775
> > Monitor:    0014698-9426FR1639
> > Disks:      Andataco PO# D409745     ST3155N 2G HB086256 10/28/2001 /u/al-d3
> >             Andataco PO# U-002844-96 ST3155N 2G HB048729 10/24/2001 /u/al-d(89)
> >             Andataco PO# U-002844-96 ST3155N 2G HB024632 10/24/2001 /u/al-d(89)
> >             Andataco PO# U-002844-96 ST3155N 2G HB048941 10/24/2001 /u/al-d2
> > Replacement:Inmartech                XP32150 2G PE62143031      /u/al-d7
> > Replacement:                                 2G             u/al-d10
> > --------------End of value--------
> >
> > Now I want to retain the above format.
> >
> > So I stored it in following format (LDIF)
> > -------
> > Description:
> >  CPU:        424M1739 UK B048407
> >  Keyboard:   0039147-9413263775
> >  Monitor:    0014698-9426FR1639
> >  Disks:      Andataco PO# D409745     ST3155N 2G HB086256 10/28/2001 /u/al-d3
> >              Andataco PO# U-002844-96 ST3155N 2G HB048729 10/24/2001 /u/al-d(89)
> >              Andataco PO# U-002844-96 ST3155N 2G HB024632 10/24/2001 /u/al-d(89)
> >              Andataco PO# U-002844-96 ST3155N 2G HB048941 10/24/2001 /u/al-d2
> >  Replacement:Inmartech                XP32150 2G PE62143031          /u/al-d7
> >  Replacement:                                 2G                     /u/al-d10
> > -----
> >
> > But while retrieving the value, I am loosing the format (looses \n).
> > I am aware that in LDIF, continuation of a line is denoted by \n followed
> > by a space. Is it true ?
> > If it is true, then how am I supposed to preserve the format.
> >
> > Thanks in advance for the help
> > Himanshu
>
> --
>  Jeff Clowser
>  mailto:jclowser@aerotek.com       Hanover MD  21076 USA
>  Phone: (410)-579-4328             7312 Parkway Drive
>
>
>